|
Post by ZF on May 22, 2014 10:23:39 GMT -5
//SYSV version: Flattening directory structures. Note that duplicates are overwritten! find -type f -exec mv '{}' . \;
//BSD version find . -type f -exec mv {} . \;
//To rename files with pattern and specific delimiter. e.g "-" for i in *.avi; do echo $i > i.txt; result=`awk -F- '{print "mv "$i" somethingsomething-"$1".avi"}' i.txt`; `$result`; done
//To test, change `` to echo. TAKE NOTE OF THE EXTENSION! for i in *.avi; do echo $i > i.txt; result=`awk -F- '{print "mv "$i" somethingsomething-"$1".avi"}' i.txt`; echo $result; done
//Removing spaces in filename for file in *; do mv "$file" "${file//[[:space:]]}"; done
//Replace specific string in files find . -depth -name '*<string.to.be.replaced>*' -execdir bash -c 'for f; do mv -i "$f" "${f//<string.to.be.replaced>/<newstring>}"; done' bash {} +
//prepend files rename 's/^/<prepended.string>/' *
//search for specific file in current directory find . -iname "*.mp4" -print
//Find and move files with space in the name find . -name '*FoooBar*' | sed 's/.*/"&"/' | xargs cp ~/foo/bar OR find -type f -name "something" -exec cp -rf '{}' <target-dir> \; find -type d -name "something" -exec cp -rf '{}' <target-dir> \;
|
|