rename photos hidden
Ermmm, how shall I put this? My girlfriend is in Germany. She sent me some photos of herself, lightly clad. I'd like to batch rename them with . in front so they are not generally visible for anyone using this computer.
Some bash command like rename /pics/.babypics/*.jpg .*.jpg How can I do this? |
Something like
Code:
cd /pics/.babypics || exit 1 EDIT: but it would be better to use permissions rather than -- or as well as -- obscurity. The same loop with chmod 600 "$f" would do it. |
Hey thanks! It's just sometimes, not very often other people use my laptop. I'd rather they didn't see her pics by accident, even though they are not exactly pornos! Using Ubuntu, with this thing called dash, I nearly showed them to a whole classroom full of students recently! Dash keeps a record of recently used files and puts a thumbnail up! Luckily, the overhead projector had gone to sleep!! But it won't show them if they are hidden!
|
Ah, OK. Then making them hidden is good enough for your needs.
Threads can be marked SOLVED via the Thread Tools menu. |
Having trouble with that, do you know what's wrong? Ihad to ctrl c to stop the terminal, it just sat there!
pedro@pedro-bedro:~/MyStuff/.bilder$ dir 14 20130126087.jpg 20130126093.jpg 20130126098.jpg 15 20130126090.jpg 20130126097.jpg 20130126099.jpg pedro@pedro-bedro:~/MyStuff/.bilder$ for f in *.jpg do echo mv "$f" ".$f" done> ^C pedro@pedro-bedro:~/MyStuff/.bilder$ ./for f in *.jpg do echo mv "$f" ".$f" done bash: ./for: No such file or directory pedro@pedro-bedro:~/MyStuff/.bilder$ ./ for f in *.jpg do echo mv "$f" ".$f" done bash: ./: Is a directory pedro@pedro-bedro:~/MyStuff/.bilder$ for f in *.jpg do echo mv "$f" ".$f" done> ^C pedro@pedro-bedro:~/MyStuff/.bilder$ |
That's probably because cmds in bash are newline separated. If you put them all on one line, you need some sort of separator.
Try it on multiple lines are per the example in a shell script. Alternately (just for fun) you can enter one line, then hit enter and you'll get an editor continuation symbol thus '>' eg Code:
# This written one line at a time, then <enter> |
Aha, so if I hit enter, instead of bash doing the command it will take the next command?
How can I enter the script then run it on the command line?? Write it with gedit, put it in the directory, then run it? Or can this be done fromthecommand line? Just for future reference! Ha, worked like a dream, just needed the ; Thanks! pedro@pedro-bedro:~/MyStuff/.bilder$ for f in *.jpg; do echo mv "$f" ".$f"; done mv 20130126087.jpg .20130126087.jpg mv 20130126090.jpg .20130126090.jpg mv 20130126093.jpg .20130126093.jpg mv 20130126097.jpg .20130126097.jpg mv 20130126098.jpg .20130126098.jpg mv 20130126099.jpg .20130126099.jpg pedro@pedro-bedro:~/MyStuff/.bilder$ |
I spoke too soon: nothing happened! When I looked in the folder /home/pedro/MyStuff/.bilder,the photos are there, names unchanged!
Something is not working!! pedro@pedro-bedro:~/MyStuff/.bilder$ for f in *.jpg; do echo mv "$f" ".$f"; done; mv 20130126087.jpg .20130126087.jpg mv 20130126090.jpg .20130126090.jpg mv 20130126093.jpg .20130126093.jpg mv 20130126097.jpg .20130126097.jpg mv 20130126098.jpg .20130126098.jpg mv 20130126099.jpg .20130126099.jpg pedro@pedro-bedro:~/MyStuff/.bilder$ dir 14 20130126087.jpg 20130126093.jpg 20130126098.jpg 15 20130126090.jpg 20130126097.jpg 20130126099.jpg pedro@pedro-bedro:~/MyStuff/.bilder$ |
Quote:
Code:
for f in *.jpg; do mv "$f" ".$f"; done |
Yeah thanks. After I read the thead again, I figured I should blip 'echo', and then it worked ok. Sorry, computers are not my thing!
|
All times are GMT -5. The time now is 10:22 PM. |