3

*Edited as I changed some things I'm currently working on a code, where a shell script searches a specific folder from the user input for jpg images. It should then sort them by date and convert them to a single picture. Here is my current code:

find . -type f -iname \*.jpg -printf | sort -t | 
convert @- -append "${filename%.*}.jpg"  

I have put it in a for loop. If I would like to rename it the the complete input, where could I add that to the code?

  • You mentioned a shell script. Can you explain how you run this script, for example do you have the script , we'll call it myscript.sh, and do you have it somehow in your $PATH so that you manually go to the folder of interest, run myscript.sh and it does the work? – clarity123 Oct 4 '15 at 20:28
  • Is there a reason you deleted the content of your question? – A.L Oct 4 '15 at 23:13
3

Just change . to "${1-.}". $1 is the first argument passed to the script, you can also default to . if no argument is passed as I've done here (by using "-", which sets a default value if the variable is unset).

Also note that your script is liable to break if any filenames contain newlines. If that matters to you, consider using find ... -print0 and sort -0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy