View previous topic :: View next topic |
Author |
Message |
Jiokah Tux's lil' helper
Joined: 28 Nov 2006 Posts: 90 Location: Toronto
|
Posted: Thu Jan 17, 2008 12:19 am Post subject: mass replace timestamp with that of a similar file? |
|
|
Hi guys,
Got a question!
I have about a hundred files that I've run a few batch commands on with Photoshop (In windows, but the files are stored on my network server, which runs Gentoo). The resulting files now have JPG extensions, with the old files having BMP extensions, with the filename itself remaining the same.
Here's what I want to do:
Transfer the timestamp of all BMP files to their counterpart JPG files.
Would any one know how? Even just a shot in the right direction will help me. I run a production web server serving many hand-built web apps built by me, so I'm not TOO far out of the woods on these things, but I'm still quite inept.
Thanks a lot!
-Matthew |
|
Back to top |
|
|
linear Apprentice
Joined: 12 Aug 2004 Posts: 222
|
Posted: Thu Jan 17, 2008 12:29 am Post subject: |
|
|
The particular utility you need for this is 'touch'.
HTH. |
|
Back to top |
|
|
MotivatedTea Apprentice
Joined: 06 Nov 2006 Posts: 269 Location: Toronto, Canada
|
Posted: Thu Jan 17, 2008 12:33 am Post subject: |
|
|
In particular, you want the "-r" parameter. So a little for loop at a bash prompt would work:
Code: | for f in *.BMP; do touch -r $f ${f/BMP/JPG}; done
|
This would set the timestamp of all JPG files to match those of the BMP files with the same name. (Extensions are case sensitive, so you may need to use "*.bmp" and "${f/bmp/jpg}". |
|
Back to top |
|
|
Jiokah Tux's lil' helper
Joined: 28 Nov 2006 Posts: 90 Location: Toronto
|
Posted: Thu Jan 17, 2008 8:56 pm Post subject: |
|
|
Ah it worked like a charm!
One last question, the syntax used here, what's it called? I'm a pro at PHP and if I could just figure out the syntax for linux I wouldn't need to learn a whole lot to get into some useful programming.
Thanks a ton! |
|
Back to top |
|
|
timeBandit Bodhisattva
Joined: 31 Dec 2004 Posts: 2719 Location: here, there or in transit
|
Posted: Thu Jan 17, 2008 9:06 pm Post subject: |
|
|
See man bash for all the gory details. The trick above is covered under Parameter Expansion. _________________ Plants are pithy, brooks tend to babble--I'm content to lie between them.
Super-short f.g.o checklist: Search first, strip comments, mark solved, help others. |
|
Back to top |
|
|
Jiokah Tux's lil' helper
Joined: 28 Nov 2006 Posts: 90 Location: Toronto
|
Posted: Thu Jan 17, 2008 9:32 pm Post subject: |
|
|
Hey thanks
By the way, your avatar rocks. Commander Keen was the best hands down. |
|
Back to top |
|
|
|