Is there any command for increment number in win cmd scrip? Need fast rename some files
>using batch
use powershell
>>56601181
install gentoo
>>56601259
/thread
>>56601181
>using the command line
>on windows
WHY would you do that if you're in the universal software development target platform? There's a program for EVERYTHING you wanna do on Windows, you don't have to suffer like on <insert_shitty_alternative_OS_name_here>.
Here you go, you can thank me later: http://www.bulkrenameutility.co.uk/
Just use a for loop or something
Or a while loop, with an increment.
>>56602444
I do not miss having to download terrible exes to do any little thing
goddomn it has been years and leaving windows was one of my best decisions ever
thanks wolfie
>not googling
https://stackoverflow.com/questions/18304025/bulk-renaming-of-files-in-powershell-with-sequential-numeric-suffixes
>nobody on /g/ is good enough at batch to just fucking answer OP's answer
I'm disappointed.@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
set ext=jpg
set n=1
set nf=0
for %%a in (*.%ext%) do (
IF !n!==1 (
set /A nf+=1
echo %%~na-!nf!.%ext%
ren %%~na.%ext% %%~na-!nf!.%ext%
)
)
ENDLOCAL
This appends a number to the end of the filename. If you wish to increment rename the files while ignoring the filenames, then simply change the "ren" line to "ren %%~na.%ext% !nf!.%ext%"
>>56603146
B-but m-muh windows can't do the things ganoo_loonix can!
Just select all files, press F2 and rename them. you will get an index at the end of the file between ( )
>>56603431
>>56603146
Holy shit, why does Windows just keep wrecking the living shit out of freenux?
IFS=$'\n'
INDEX=1
for filename in $(ls -1 *.jpg) ; do
mv "$filename" $INDEX
INDEX=$($INDEX+1 | bc)
done
[\code]
Might not work perfectly, haven't tried it.
>>56603505
Should beINDEX=$(echo $INDEX+1 | bc)
Now it works (also I fucked up the code tag)
>>56603837
Err... replace that for with foreach. Fucked up in typing it.
>>56603837
>Isn't that SIGNIFICANTLY EASIER TO UNDERSTAND?
no because i hate powershell and have been using batch for ages so this is not an issue.
Again realized I fucked up the script. Should be:$files = gci *.jpg
$count = 0
foreach ($file in $files) {
ren $file $($file.ToString().Replace(".jpg", "$count.jpg"))
$count += 1
}
But I digress, easier.
>>56603937
>have been using batch for ages
Yes, well, use something else. Your scripts are going to be a pain in the ass to maintain for anyone who isn't you. Windows supports Bash right now as well, so if you don't like Powershell, use Bash. Or write a script in Python or Ruby or Perl. Really, anything but that shit language that should have never existed.