Skip to content

Commit

Permalink
Delete duplicate files recurively
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshlinux committed Apr 16, 2018
1 parent ca58575 commit 497ba43
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 2 deletions.
1 change: 0 additions & 1 deletion delete All File with extension_EXE.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#-------------------------------------------------------------------------------
import glob
import os

def main():
directory='C:\\Users\\acer\\Desktop\\HigherThinkingC++'
os.chdir(directory)
Expand Down
28 changes: 28 additions & 0 deletions delete_duplicate_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# purpose : To search and delete duplicate files
# name : rakesh kumar
# licence : MIT
import os
import sys #module for terminating
import glob
import tkinter as tk
from tkinter import filedialog

count=0
root = tk.Tk()
root.withdraw()
sourcedir = filedialog.askdirectory()
os.chdir(sourcedir)
source_files = glob.glob('*.*')
targetdir = filedialog.askdirectory()
if not targetdir.strip() :
print ( "Folder Error...User did not selected any folder" )
#rootdir = 'C:\\Users\\ace
sys.exit()
for root, subFolders, files in os.walk(targetdir):
os.chdir(root)
files = glob.glob('*.*')
for filename in files:
if filename in source_files:
os.unlink(filename)
count+=1
print ( "Total {} files deleted" .format(count) )
47 changes: 47 additions & 0 deletions file.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Program to Find the Largest & Smallest Word in a String
made by : rakesh kumar
*/
#include <iostream>
#include <string.h>
#include <ctype.h>
using namespace std;
int main()
{
char string[100], word[20], max[20], min[20], c;
int i = 0, j = 0, flag = 0;
cout<<"Enter string: ";
cin.getline(string,100);

//processing phase
for (i = 0; i < strlen(string); i++)
{
while (i < strlen(string) && !isspace(string[i]) && isalnum(string[i]))
{
word[j++] = string[i++];
}
if (j != 0)
{
word[j] = '\0';

if (flag==0) // this will run only once
{
flag = 1;
strcpy(max, word);
strcpy(min, word);
}
if (strlen(word) > strlen(max))
{
strcpy(max, word);
}
if (strlen(word) < strlen(min))
{
strcpy(min, word);
}
j = 0; // for next word in the string
}
}

//output phase
cout<<"The largest word is '"<<max <<"' and smallest word is '"<<min<<"' in ''"<<string<<"'";
return 0;
}
2 changes: 1 addition & 1 deletion folders_recursivly.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def compressFile(source):
file2 = open("temp.dat","w")
data = file.read();
file2.write(re.sub('[\s]+',' ',data))
file.close();
file.close()
file2.close()
os.remove(source)
os.rename('temp.dat',source)
Expand Down

0 comments on commit 497ba43

Please sign in to comment.