Wednesday, May 24, 2017

[TERMINAL] - Move file to folder based by name file.

This command iterate over all PDF files, create a folder with same name of file and move the file to inside.

for i in *.pdf; do folderName=`echo "$i"|cut -d- -f1`; mkdir -p "$folderName"; mv "$i" "$folderName"; done

You can use for PDF or other extension file, just change *.pdf to *.doc, or *.jpg, ...

No comments :

Post a Comment