Mogrify doesnt work in .bat-file. What to do?
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Mogrify doesnt work in .bat-file. What to do?
mkdir SDtemp
copy *@2x*.png SDtemp
mogrify -format png -resize 50%% SDtemp/*@2x*.png {-> This Step doesn´t work!}
pushd SDtemp
setlocal enableDelayedExpansion
for %%a in (*.png) do (
set "filename=%%~nxa"
set "purged_filename=!filename:@2x=!"
ren %%~nxa !purged_filename!
)
endlocal
The program should do:
1. Create in the same folder a folder called "SDtemp".
2. Copy all "@2x" out of it into SDtemp. (Example: example@2x.png)
3. Change all names without @2x. (Example: exmaple@2x.png -> example.png)
4. Resize all png´s to 50%-
Step 1 works. Step 2 works. Step 3 works. Step 4 doesn´t!
So does it looks like;
http://img5.fotos-hochladen.net/uploads ... fuhxmo.png
.bat-file Download:
http://www.mediafire.com/download/c50cv ... HDtoSD.bat
I know that it works with cmd.exe. But i never used it...
Can u help me to create an cmd.exe file for this? Or is their another way with .bat?
PS: You can send me a private message too. (I also got Skype/TS)
Much Thanks
MomentumHunt91
copy *@2x*.png SDtemp
mogrify -format png -resize 50%% SDtemp/*@2x*.png {-> This Step doesn´t work!}
pushd SDtemp
setlocal enableDelayedExpansion
for %%a in (*.png) do (
set "filename=%%~nxa"
set "purged_filename=!filename:@2x=!"
ren %%~nxa !purged_filename!
)
endlocal
The program should do:
1. Create in the same folder a folder called "SDtemp".
2. Copy all "@2x" out of it into SDtemp. (Example: example@2x.png)
3. Change all names without @2x. (Example: exmaple@2x.png -> example.png)
4. Resize all png´s to 50%-
Step 1 works. Step 2 works. Step 3 works. Step 4 doesn´t!
So does it looks like;
http://img5.fotos-hochladen.net/uploads ... fuhxmo.png
.bat-file Download:
http://www.mediafire.com/download/c50cv ... HDtoSD.bat
I know that it works with cmd.exe. But i never used it...
Can u help me to create an cmd.exe file for this? Or is their another way with .bat?
PS: You can send me a private message too. (I also got Skype/TS)
Much Thanks
MomentumHunt91
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Mogrify doesnt work in .bat-file. What to do?
What happens? Do you get an error message? What happens if you put "-verbose" at the first command to mogrify?This Step doesn´t work!
snibgo's IM pages: im.snibgo.com
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
x
Last edited by MomentumHunt91 on 2015-08-03T16:10:19-07:00, edited 1 time in total.
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
Like in the .png i linked.
I don´t get an error message. It got the size 136x136 before and after i use this...
mogrify -verbose -format png -resize 50%% SDtemp/*@2x*.png
That didn´t work...
I don´t get an error message. It got the size 136x136 before and after i use this...
-> Never did that. Can u code it? So i will try it.MomentumHunt91 wrote:What happens if you put "-verbose" at the first command to mogrify?
mogrify -verbose -format png -resize 50%% SDtemp/*@2x*.png
That didn´t work...
Re: Mogrify doesnt work in .bat-file. What to do?
I do not see an error message in the linked png.
Seems to me that you would want to do the mogrify after the renaming , not before.
wonder if the characters "/@" is causing trouble. Think you meant "\@" .
does "@" require escaping when using Windows?
Seems to me that you would want to do the mogrify after the renaming , not before.
wonder if the characters "/@" is causing trouble. Think you meant "\@" .
does "@" require escaping when using Windows?
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
There isn´t an error message. It just doesn´t scale the picture to the right size the rest works.ceepea wrote:I do not see an error message in the linked png.
You can test it too. Linked a downloadlink in down on my main post. Just get a folder with a png called XXX@2x.png.
I actually don´t look up on the order. I just wish it works. :pceepea wrote:Seems to me that you would want to do the mogrify after the renaming , not before.
Tried out with "\@" doesn´t work neither...ceepea wrote:wonder if the characters "/@" is causing trouble. Think you meant "\@" .
It doesn´t.ceepea wrote:does "@" require escaping when using Windows?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Mogrify doesnt work in .bat-file. What to do?
In IM @ is a special character that indicates a file to be used, such as @file.txt. I do not think @ works in mogrify, only convert. Do you mean to use it as a wild card in some way? If so, then use *. In a batch file, to escape some character you need to use ^ rather than \. So ^@, if the @ is a character in your image names. But I do not think mogify can have that kind of wild card usage to specify some directory. I think you need to cd to the directory your images are in. Then use the -path option to mogrify to specify the output directory. Then use just * at the end. You may be able to use *@2x*.png. I am not sure of that, but I am pretty sure you cannot have a directory specified that way. You need to use -path for the output directory.
Sorry I am not a windows user, so do not know windows wildcards and escapes that well.
Sorry I am not a windows user, so do not know windows wildcards and escapes that well.
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
Ye it´s an @txt.file.In IM @ is a special character that indicates a file to be used, such as @file.txt.
I do not think @ works in mogrify, only convert. Do you mean to use it as a wild card in some way? If so, then use *. In a batch file, to escape some character you need to use ^ rather than \. So ^@, if the @ is a character in your image names. But I do not think mogify can have that kind of wild card usage to specify some directory.
I don´t know much about a batch file.... It would be awesome if u can help to create this little file with me...
This actually isn´t possible. I want to reupload it on my "userpage" after. And it´ll be a free upload for the game "osu". So it need to work for any downloader. Specificaly cd /path" won´t work for me.I think you need to cd to the directory your images are in. Then use the -path option to mogrify to specify the output directory. Then use just * at the end. You may be able to use *@2x*.png. I am not sure of that, but I am pretty sure you cannot have a directory specified that way. You need to use -path for the output directory.
The game "osu" got always a "skin"-folder u can change. I want to create this file to automaticaly create an SD folder that close the half work for all.
It got the normal .png´s (SD) and the "@2x" .png´s (HD). The program should search all the "@2x" files and create a new folder where u find all "SD"-files [-50% size].
Here is a picture about it:
http://img5.fotos-hochladen.net/uploads ... 8n2v3k.png
Re: Mogrify doesnt work in .bat-file. What to do?
what happens when you try the setup with files that do not "@" or any other non-alphanumeric characters?
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
I try it out and edit this soon gimme a second.ceepea wrote:what happens when you try the setup with files that do not "@" or any other non-alphanumeric characters?
EDIT: Tried it out now. It does the same thing. Copy all from the Input-folder right to the Output-folder. Change all the names to the right way. But it still doesnt change the sitz to -50%....
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Mogrify doesnt work in .bat-file. What to do?
You cannot use an @textfile.txt in mogrify. That only works with convert. Moreover, there is no input in mogrify, only the * for the output. Convert allows @textfile.txt for input, but not output. Furthermore, IM does not create new directories. They have to be created first before referencing them in command. So you will need to make your batch file script use OS commands to create directories and change directories. There are windows equivalents to cd, if it does not allow that. You will need to use -path to specify the existing output directory in mogrify.
Sorry I am not a Windows user and know relatively nothing about scripting on Windows.
Sorry I am not a Windows user and know relatively nothing about scripting on Windows.
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
Good to know. And thanks for that. So i will keep going and say that i want to convert all data´s to the input folder with the right size. And yes i just used the mogrify for the Output.fmw42 wrote:You cannot use an @textfile.txt in mogrify. That only works with convert. Moreover, there is no input in mogrify, only the * for the output. Convert allows @textfile.txt for input, but not output.
But i actually tried that and don´t know how that really works. I watches some guides for the right command but I always did something wrong. Can u help me with this?
Last edited by MomentumHunt91 on 2015-08-03T18:18:16-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Mogrify doesnt work in .bat-file. What to do?
Please read about batch scripting by searching google or from http://www.imagemagick.org/Usage/windows/
-
- Posts: 26
- Joined: 2015-08-03T14:15:55-07:00
- Authentication code: 1151
Re: Mogrify doesnt work in .bat-file. What to do?
I actually just need 1 command now:fmw42 wrote:Please read about batch scripting by searching google or from http://www.imagemagick.org/Usage/windows/
To convert all "xxx.2x" data´s to xxx data´s with the right size. (The folder can be the Input folder it´s fine.)
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Mogrify doesnt work in .bat-file. What to do?
Typical procedure is:MomentumHunt91 wrote:Good to know. And thanks for that. So i will keep going and say that i want to convert all data´s to the input folder with the right size. And yes i just used the mogrify for the Output.fmw42 wrote:You cannot use an @textfile.txt in mogrify. That only works with convert. Moreover, there is no input in mogrify, only the * for the output. Convert allows @textfile.txt for input, but not output.
But i actually tried that and don´t know how that really works. I watches some guides for the right command but I always did something wrong. Can u help me with this?
create output directory, if it does not exist.
cd to input directory
Code: Select all
mogrify -format png -path full_path_to/output_directory -resize WxH *
If you just want to process input png files, then use
Code: Select all
mogrify -format png -path full_path_to/output_directory -resize WxH *.png