View Single Post
Old January 8th, 2013, 08:16 PM   #227 (permalink)
MoodyBlues
- Crazy peacock person -
 
MoodyBlues's Avatar
 
Join Date: Jan 2011
Location: /home/LosAngeles
Posts: 3,063
 
Device(s): Kindle Fire HD 8.9" (rooted), Motorola Atrix 2, Motorola Atrix 4G (retired), Motorola Bravo (retired
Carrier: AT&T

Thanks: 1,027
Thanked 1,475 Times in 896 Posts
Default

Quote:
Originally Posted by argedion View Post
awesome but i cheated some and had a friend help me with a bash script that uses exiftool
Great!

Quote:
it has a few flaws but does work maybe we can come up with something.
Taking the time to learn bash scripting yourself would be *SO* worth it in the long run. You really can't appreciate the built-in power of *nix until you see what you can do with its basic tools.

Quote:
At moment filenames with spaces are a no no so i'll have to rename those that have spaces in them.
Want to do them all at once? Like in a few seconds? This will change spaces in file names to underscores.

Code:
#!/bin/bash

ls > /tmp/current_files
mv /tmp/current_files ./current_files
cat current_files | tr ' ' '_' > current_files_new
FileCount=$(wc -l current_files | awk '{print $1}')
count=1
while   [ "$count" -le "$FileCount" ]
do 	ReadAwk="FNR=="$count
	OldName=$(awk $ReadAwk current_files)
	NewName=$(awk $ReadAwk current_files_new)
	mv "$OldName" "$NewName" > /dev/null 2>&1
	count=$(($count+1))
done
rm current_files
rm current_files_new
exit 0
DISCLAIMER: I referred to some old notes, wrote this quickly, tested it quickly, didn't waste time documenting or making it elegant--but it works. However, for your own comfort it'd be best to try it in a temporary directory with COPIES of the files you're working with. Then you can verify that it's working as expected, without risking losing anything or messing things up somehow. Also, if you're unsure what any part of it is doing, feel free to ask!

Quote:
Also as you can see can only do one type at a time
My suggested way (bash scripting plus ImageMagick) wouldn't limit you like that, because IM can determine the file type on its own. But for right now, if it's working out okay, just stick with it.

Quote:
on the fedora site my signature is Command Line Flunkie Gui Junkie

I wish to change this


Quote:
Originally Posted by argedion View Post
what is the easiest way to rename files by just removing the spaces in the name?
I was in the process of writing the above, but got distracted and by the time I got back to it, you'd posted your question about the very thing I was going to write about!
MoodyBlues is online now  
Reply With Quote
The Following 2 Users Say Thank You to MoodyBlues For This Useful Post:
argedion (January 8th, 2013), ocnbrze (January 8th, 2013)