-
Need Windows scripts conversion for Linux environment...
I have a script that I use often in Windows, for renaming files.
Specifically, the script removes the first couple of digits from system files, and leaves the last 2 digits -
HPIM_00.jpg,
HPIM_01.jpg,
HPIM_02.jpg, etc., ...
and gives
00.jpg
01.jpg
02.jpg, etc., ...
This is the script in 'Windese':
Setlocal EnableDelayedExpansion
PushD "J:\home\chuck-04d0\Desktop\Beach"
For /F "Tokens=1 Delims=" %%I In ('dir /A-D /B IMG_*.JPG') Do (
Set _tmp=%%I
Set _tmp=!_tmp:~1!
Ren "%%I" "!_tmp! "
)
PopD
What would it look like in Torvaldese???
-
Code:
for i in `ls -1 *.[jJ][pP][gG]`
do
newfilename=`echo $i | cut -f 2 -d \_`
mv $i $newfilename
done
Or similar should do it ... or at least get you started.
-
Thanks there ph34r...
Is the script, as you posted it, the entire contents of the script file?
What will be the file extension?
Thanks again there...
-
Originally Posted by buccaneere
Thanks there ph34r...
Is the script, as you posted it, the entire contents of the script file?
What will be the file extension?
Thanks again there...
Missing the first line - should start with
#!/bin/bash
Linux doesn't care about extensions - just make the script executable.
-
How do I target ONLY files in a particular folder - using my earlier example, for instance...
J:\home\chuck-04d0\Desktop\Beach
What is ls -l ?
Thanks again...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|