bergman on 17 Nov 2018 17:51:48 -0800 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: [PLUG] scripting help, variables in sed |
In the message dated: Sat, 17 Nov 2018 20:21:03 -0500, The pithy ruminations from Tone Montone on [Re: [PLUG] scripting help, variables in sed] were: => I seem to remember an emergency disk recover tool that did this. It svcanned all is mages on a disk or folder, separataed them based on type, or dates, or other otpions photorec Mark => => Sent from my iPhone => => > On Nov 17, 2018, at 7:22 PM, bergman@merctech.com wrote: => > => > In the message dated: Fri, 16 Nov 2018 09:45:35 -0500, => > The pithy ruminations from Michael Lazin on => > [[PLUG] scripting help, variables in sed] were: => > => My girlfriend has a large collection of scanned family photos many of which => > => are different photos with the same name. We eliminated all duplicates with => > => fdupes, but she would like to put them all in one folder and give it to her => > => sisters on a cd. => > => => > => I had a bit of free time this morning and tried to write a for loop to => > => accomplish this but I'm getting syntax errors and I'm kinda stuck. Any => > => help would be appreciated. Here is my code so far: => > => => > => #!/bin/bash => > => var=1 => > => for i in *.jpg; do sed -i -e "s/"($i)"/"($var++)""($i)/" ; done => > => > => > i=1 ls -1 *.jpg |while read filename; do mv $filename ${i}_${filename}; i=$((i+1)) ; done => > => > Substitute "ls -1" with "find", change the target of "mv" to include a => > directory, etc. => > => > For bonus points...eliminate the $i variable and use options in "ls" => > (or "find") to preceed the target filename with the source file's inode => > number, guaranteeing a unique number (for a given filesystem). => > => > Or => > i=1 ls -1 |awk '{print "mv " $1 " " NR "_" $1}' | sh => > => > Mark => > => > => => > => Thanks, => > => => > => Michael => > => => > => -- => > => Michael Lazin => > => => > => to gar auto estin noein te kai ennai => > => => > ___________________________________________________________________________ => > Philadelphia Linux Users Group -- http://www.phillylinux.org => > Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce => > General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug => => -- Mark Bergman Biker, Rock Climber, SCUBA Diver, Unix mechanic, IATSE #1 Stagehand '94 Yamaha GTS1000A^1 2015 Aprilia Caponord bergman@panix.com https://www.flickr.com/photos/rmsppu I want a newsgroup with a infinite S/N ratio! Now taking CFV on: rec.motorcycles.stagehands.pet-bird-owners.pinballers.unix-supporters 15+ So Far--Want to join? Check out: http://www.panix.com/~bergman ___________________________________________________________________________ Philadelphia Linux Users Group -- http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion -- http://lists.phillylinux.org/mailman/listinfo/plug