user3566608
user3566608

Reputation: 353

Windows ImageMagick/bat remove part of the name

I'm not very into all this stuff, but I somehow managed to do it (wasn't really hard)

but I can't find out how to remove parts from the file name

my code looks like this

mkdir SD
copy *@2x*.png SD
mogrify -format png -resize 50% SD/*@2x*.png

What it does : it makes a new folder, copies all png images with "@2x" in their name to the new folder and then resizes them.

I want to remove the "@2x" from all resized images

Can anyone help me?

Upvotes: 1

Views: 151

Answers (1)

npocmaka
npocmaka

Reputation: 57272

@echo off
mkdir SD
copy *@2x*.png SD
mogrify -format png -resize 50% SD/*@2x*.png
pushd SD

setlocal enableDelayedExpansion
for %%a in (*.png) do (
    set "filename=%%~nxa"
    set "purged_filename=!filename:@2x=!"
    ren %%~nxa !purged_filename!
)

endlocal

popd

Upvotes: 1

Related Questions