PDA

View Full Version : Finding Multiple Files - How



Rodney9
20th October 2007, 05:11 PM
Hello,

I am getting ready for Leopard and backing up files to DVD, after the DVD is burnt I wish to find where all these files are on the hard drive to delete them.
Is there a way to search for the same multiple files ?

Rodney.

Currawong
20th October 2007, 05:31 PM
What files in particular do you want to delete?

SyncMan
20th October 2007, 05:33 PM
Is there a way to search for the same multiple files ?

File Buddy (http://www.skytag.com/)?

Rodney9
20th October 2007, 07:25 PM
What files in particular do you want to delete?

The same files on the DVD, all types, jpg, dmg, txt, etc

Rodney9
20th October 2007, 07:27 PM
File Buddy (http://www.skytag.com/)?

File Buddy is $45 !

Isn't there a way to find these multiple files with finder ?

Currawong
20th October 2007, 07:53 PM
How did you find the files in the first place to back them up? Sorry if it sounds like a stupid question, but I feel i'm missing info here.

Rodney9
20th October 2007, 08:12 PM
How did you find the files in the first place to back them up? Sorry if it sounds like a stupid question, but I feel i'm missing info here.

I just drag the files, some in Pictures, some in Documents etc, I want in Finder to Toast.

tcn33
20th October 2007, 08:21 PM
Highlight the files in Toast, right-click and select Reveal In Finder, then delete them.

Rodney9
21st October 2007, 12:41 PM
Highlight the files in Toast, right-click and select Reveal In Finder, then delete them.
This does not work, I select all, then right click and all that happens is the file I'm closest to gets selected only.

I dragged 4132 unique files to Toast and burnt and burned the dvd, now I wish to find all these on my hard drive.

Rodney9
21st October 2007, 01:25 PM
I tried copying from Toast and pasting the 4132 files into finder/search but still after 30 minutes it has not found one.

This used to be so easy with xtree gold or windows commander, you could compare directories, there must be some way in Tiger.

chrism238
21st October 2007, 01:28 PM
File Buddy is $45 !

Isn't there a way to find these multiple files with finder ?OK, please don't tell Brains that this works and that it took me 5 minutes to write and debug, but you can use this shellscript for free ;). Identical files will have the same first column:


#!/bin/sh

if [ $# != 2 ]; then
echo "Usage: samefile dirname1 dirname2" ; exit 1
fi

rm -f .f?-$$

find $1 -type f | sed 's/.*/"&"/' >> .f1-$$
find $2 -type f | sed 's/.*/"&"/' >> .f1-$$

sort < .f1-$$ | xargs md5sum > .f2-$$

cut '-d ' -f1 < .f2-$$ | uniq -c | grep -v ' 1' | cut -f2 > .f3-$$

for i in `cat .f3-$$`
do
grep $i .f2-$$
done

rm -f .f?-$$

Rodney9
21st October 2007, 01:37 PM
OK, please don't tell Brains that this works and that it took me 5 minutes to write and debug, but you can use this shellscript for free ;). Identical files will have the same first column:


#!/bin/sh

if [ $# != 2 ]; then
echo "Usage dirname1 dirname2" ; exit 1
fi

rm -f .f?-$$

find $1 -type f | sed 's/.*/"&"/' >> .f1-$$
find $2 -type f | sed 's/.*/"&"/' >> .f1-$$

sort < .f1-$$ | xargs md5sum > .f2-$$

cut '-d ' -f1 < .f2-$$ | uniq -c | grep -v ' 1' | cut -f2 > .f3-$$

for i in `cat .f3-$$`
do
grep $i .f2-$$
done

rm -f .f?-$$

Thank You but excuse my ignorance, what does this do and how do I use it, in the terminal or what ?

chrism238
21st October 2007, 02:48 PM
Thank You but excuse my ignorance, what does this do and how do I use it, in the terminal or what ?Yes, it's a shellscript (an executable list of commands) that can be saved to a text file, and executed (all via the Terminal) to address your problem. If invoked with:

samefile dirname1 dirname2

it will list all files that are found in both of the named directories. Having just copied a bunch of files from hard disk to DVD, it will locate the original copies on the hard disk, and you can then delete them with other commands, such as rm filename.

Rodney9
21st October 2007, 03:21 PM
Sorry another dum question, what is the directory name for a mounted dvd and my home directory, is it mnt/dvd and /home ?

raf
21st October 2007, 03:34 PM
Home directory is /Users/<username> or even simpler, ~ (tilde).

Drives you mount are in /Volumes/<volumename>

You can always use TAB to have Terminal give you a possible list of autocompletions.

example: If a DVD is labelled "DVD1", it would be at /Volumes/DVD1/

Rodney9
21st October 2007, 03:44 PM
When I copy -

#!/bin/sh

if [ $# != 2 ]; then
echo "Usage: samefile /Users/me /Volumes/Pics&DLoads" ; exit 1
fi

rm -f .f?-$$

find $1 -type f | sed 's/.*/"&"/' >> .f1-$$
find $2 -type f | sed 's/.*/"&"/' >> .f1-$$

sort < .f1-$$ | xargs md5sum > .f2-$$

cut '-d ' -f1 < .f2-$$ | uniq -c | grep -v ' 1' | cut -f2 > .f3-$$

for i in `cat .f3-$$`
do
grep $i .f2-$$
done

rm -f .f?-$$

Into terminal , I get the following -

rodney-mitchells-mac-mini:~ me$ #!/bin/sh
-bash: !/bin/sh: event not found
rodney-mitchells-mac-mini:~ me$
rodney-mitchells-mac-mini:~ me$ if [ $# != 2 ]; then
> echo "Usage: samefile /Users/me /Volumes/Pics&DLoads" ; exit 1
> fi
Usage: samefile /Users/me /Volumes/Pics&DLoads
logout
[Process completed]

What now ?

Currawong
21st October 2007, 03:45 PM
You know, regarding dragging files to the trash, you can just type, after selecting the files: command-backspace and they will be moved to the trash? However, there's no way the system knows what you copied to DVD already and what you didn't. If you spend ages going around your folders selecting individual or groups of files or whatever, then you're very stuck. I tend, after copying files i know I will probably want to delete later, to change them to grey in the Finder so I know for future reference that they can be safely deleted.

Rodney9
21st October 2007, 07:45 PM
When I copy -

#!/bin/sh

if [ $# != 2 ]; then
echo "Usage: samefile /Users/me /Volumes/Pics&DLoads" ; exit 1
fi

rm -f .f?-$$

find $1 -type f | sed 's/.*/"&"/' >> .f1-$$
find $2 -type f | sed 's/.*/"&"/' >> .f1-$$

sort < .f1-$$ | xargs md5sum > .f2-$$

cut '-d ' -f1 < .f2-$$ | uniq -c | grep -v ' 1' | cut -f2 > .f3-$$

for i in `cat .f3-$$`
do
grep $i .f2-$$
done

rm -f .f?-$$

Into terminal , I get the following -

rodney-mitchells-mac-mini:~ me$ #!/bin/sh
-bash: !/bin/sh: event not found
rodney-mitchells-mac-mini:~ me$
rodney-mitchells-mac-mini:~ me$ if [ $# != 2 ]; then
> echo "Usage: samefile /Users/me /Volumes/Pics&DLoads" ; exit 1
> fi
Usage: samefile /Users/me /Volumes/Pics&DLoads
logout
[Process completed]

What now ?

What now ?

chrism238
21st October 2007, 08:16 PM
Hello Rodney; what you need to do it:

- place all of these commands into a single file using any text editor (such as TextEdit) named
findsame

- from Terminal's command-line type the command
chmod 700 findsame

- from Terminal's command-line (with the DVD still mounted) type the command:
./findsame /Volumes/DVDname directory-name-from-where-files-copied

You will get a list of filename, each preceded by a "meaningless" string.
Each line commencing with the same string is a duplicate, and all but one of them can be removed with the command:

rm duplicatefilesname

Hope this helps,

Rodney9
22nd October 2007, 12:47 PM
This what I get -

rodney-mitchells-mac-mini:~ me$ ./findsame /Volumes/Pics&DLoads /me
[1] 3659
-bash: DLoads: command not found
./findsame: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf410: command not found
rodney-mitchells-mac-mini:~ me$ ./findsame: line 2: syntax error near unexpected token `}'
./findsame: line 2: `{\fonttbl\f0\fmodern\fcharset77 Courier;}'

soulman
22nd October 2007, 01:34 PM
Why don't you just drag your files to a disk image then delete that when you're finished? Hold the Command key when dragging and your files will be moved - actually copied then deleted - rather than just copied to the disk image.

Rodney9
22nd October 2007, 02:38 PM
Why don't you just drag your files to a disk image then delete that when you're finished? Hold the Command key when dragging and your files will be moved - actually copied then deleted - rather than just copied to the disk image.

Well I will in future now I know, but I burnt the dvd before I knew this and as I have said finding same multiple files in dos (xtree gold), linux (midnight commander) and god forbid even windows (total commander) was easy, so silly me presumed it would be even easier in Tiger.

mab
22nd October 2007, 03:27 PM
This what I get -

rodney-mitchells-mac-mini:~ me$ ./findsame /Volumes/Pics&DLoads /me
[1] 3659
-bash: DLoads: command not found
./findsame: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf410: command not found
rodney-mitchells-mac-mini:~ me$ ./findsame: line 2: syntax error near unexpected token `}'
./findsame: line 2: `{\fonttbl\f0\fmodern\fcharset77 Courier;}'


[1] 3659
-bash: DLoads: command not found

This error is caused by the & in the name you could try

me$ ./findsame /Volumes/Pics\&DLoads /me
note the back slash. But the script will more that likely break somewhere else

chrism238
22nd October 2007, 03:51 PM
But the script will more that likely break somewhere elseGee; thanks for the vote of unsubstantiated confidence :(

mab
22nd October 2007, 03:58 PM
Gee; thanks for the vote of unsubstantiated confidence :(

Sorry:)
It should work OK as long as he has no spaces or &'s in the directory or file names.

Rodney9
22nd October 2007, 04:18 PM
I now get -

rodney-mitchells-mac-mini:~ me$ ./findsame /Volumes/Pics\&DLoads /me
./findsame: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf410: command not found
./findsame: line 2: syntax error near unexpected token `}'
./findsame: line 2: `{\fonttbl\f0\fmodern\fcharset77 Courier;}'

Thank You Chris and Mab for trying.

mab
22nd October 2007, 06:17 PM
Rodney9
Can you post or PM me the output from

find /Volumes/Pics\&DLoads -type f -print

from the terminal.
and I will have a look a what's going on

rtc
22nd October 2007, 06:24 PM
In future.

1. Find the files you want to back up and change the label of each to a certain colour (say yellow). Instead of dragging to the toast window.

2. Do a search for all files with yellow label and drag from results window to toast window. Then backup.

3. then do a search for yellow label files and drag from results window to trash.

OR you could do via aliasing into a new folder, and burning the contents of new folder with toast set to resolve aliases (can't remember how to do this). Then use an applescript to step through the aliases and a) find original, b) move currently selected file to trash c) go back to alias folder d) delete alias e) repeat.

BUt the first way sounds the easiest. NOTE: NOT TESTED.

I know this doesn't answer your actual question, and i agree there should be a max OSX answer, but in case you may also want a practical solution, try the one above?

mab
22nd October 2007, 06:34 PM
I now get -

rodney-mitchells-mac-mini:~ me$ ./findsame /Volumes/Pics\&DLoads /me
./findsame: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf410: command not found
./findsame: line 2: syntax error near unexpected token `}'
./findsame: line 2: `{\fonttbl\f0\fmodern\fcharset77 Courier;}'

Thank You Chris and Mab for trying.
also the /me is that correct? if you had copied the files from somewhere in your home folder it should be something like /Users/"your-login-name"

Rodney9
22nd October 2007, 07:31 PM
Still get -

rodney-mitchells-mac-mini:~ me$ ./findsame /Volumes/Pics\&DLoads /Users/me
./findsame: line 1: {rtf1macansicpg10000cocoartf824cocoasubrtf410: command not found
./findsame: line 2: syntax error near unexpected token `}'
./findsame: line 2: `{\fonttbl\f0\fmodern\fcharset77 Courier;}'

Isn't there a file manger like xtree for Tiger to make this easy ?

mjankor
22nd October 2007, 08:13 PM
Rodney have a look on versiontracker or macupdate and see if there's anything you like the look of.

Rodney9
23rd October 2007, 01:38 PM
Rodney have a look on versiontracker or macupdate and see if there's anything you like the look of.

Thankyou Everyone for advice and help.

I tried mucommander, diskorder and xfolders.

XFolders was the easiest and free, it compared the directories so quickly and easy, seems ridiculous that finder can't do this.