shell - How to develop this sort script further -
i have small interactive unix script takes terminal command input chosen file type , upon receiving such iterates through large folder of unsorted files on desktop , pulls files of chosen selection new sorted folder.
i.e. user types jpg in command , jpg files pulled out of unsorted folder , sorted folder.
it works terrific stands, develop script further instead of file types being pushed communal sorted folder, have jpg files being pushed dedicated folderjpg, png files pushed in folderpng , docx files moved docxfolder.
how can achieve such in leanest possible manner assuming these dedicated folders file types mentioned have been created on desktop.
#!/bin/bash echo "good morning, please enter file type name sorting [enter]:" read extension mv -v /users/christopherdorman/desktop/unsorted/*.${extension} /users/christopherdorman/desktop/sorted/ if [[ $? -eq 0 ]]; echo "good news, files have been processed" fi
i write way:
read -p "good morning, please enter file type name sorting [enter]:" extension if cd /users/christopherdorman/desktop; destination="folder$extension" # ensure destination folder exists mkdir -p "$destination" if mv -v unsorted/*."$extension" "$destination"; echo "good news, files have been processed" fi fi
Comments
Post a Comment