Wednesday, October 21, 2009

Renaming huge amount of files

There are a lot of scripts to renames files, but these are two choices:

for & sedfor F in * ; do mv “$F” `echo “$F” | sed ’s/{search_string}/{replace_string}/’ ` ; done


The other choice is to use the command 'mmv'. I never used it, but seems that it works.

Monday, October 12, 2009

Diff two directories

If we wanted to find the differences between 2 directories we can use this commands:

ls -R$ ls -R 'directory1' > ls_dir1
$ ls -R 'directory2' > ls_dir2

Then we will change each file directory names for the same name. This way we could get better diff file.
sed$ sed -e 's/directory1/diff_name/' ls_dir1 > ls_dir1_sed
$ sed -e 's/directory2/diff_name/' ls_dir2 > ls_dir2_sed

And finally we'll do the diff, to see the differences:
diff
$ diff ls_dir1_sed ls_dir2_sed | more


Sed: http://www.gentoo.org/doc/es/articles/l-sed2.xml