Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by coerrace
at 2024-07-30 18:19:34
Point:500 Replies:17 POST_ID:829175USER_ID:12067
Topic:
MS DOS;Windows Batch Scripting;Miscellaneous Programming
hello I want to convert pdf to jpg in a batch and I'm using the:http://www.imagemagick.org/
They way to use is simply:
They way to use is simply:
Now I want to do a batch in command prompt. I have a directory called c:data inside that directory there are a lot of sub directories each directory by the same way inside has different pdf files with different names then I want that the batch look for all sub directories inside c:data and then look inside each sub directory for the pdf files if found convert that pdf file inside the same directory where was found and exist the pdf found and with the same name than the original pdf and on that way with all sub directories and all pdf files. Of course some of that sub directories contain a lot of pdf files another sub directories have just one pdf or two and some has other kind of formats like flv, doc or whatever and that other formats different than pdf must not be touched must be converted the pdf files only. I tried to do this batch but doesn't work:
Could anyone can help me in modify the script to make work and put the code?
Thank you so much
Expert: duncanb7 replied at 2024-07-31 09:16:12
thx for your pt
ve a nice day
duncan
ve a nice day
duncan
Expert: Joe Winograd replied at 2024-07-31 09:13:46
I'm leaving my office now for around 3-4 hours. I'll look at your new question as soon as I return. Regards, Joe
Author: coerrace replied at 2024-07-31 07:29:05
I opened this new question just for a modification if you can help there:
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_28487736.html
Thank you
http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_28487736.html
Thank you
Expert: Joe Winograd replied at 2024-07-31 07:17:33
> if I run from c: emp for example not work
Hmmm, I don't understand that. I haven't tried Duncan's solution, but I can tell you that mine should work fine running from c: emp (in my test, I used d: tempd est and it worked fine). In any case, you're welcome — and I'm glad you got it working! Regards, Joe
Hmmm, I don't understand that. I haven't tried Duncan's solution, but I can tell you that mine should work fine running from c: emp (in my test, I used d: tempd est and it worked fine). In any case, you're welcome — and I'm glad you got it working! Regards, Joe
Author: coerrace replied at 2024-07-31 06:20:57
Both scripts worked is just needed to run in my case in c: if I run from c: emp for example not work but from c: all perfect.
Thank you
Thank you
Expert: duncanb7 replied at 2024-07-30 22:21:12
del command , just delete junk.txt temp file only after finishing all convert, that file
is not related to convert
I have checked the script is working I used "copy" to simulate "convert" effect
Duncan
is not related to convert
I have checked the script is working I used "copy" to simulate "convert" effect
Duncan
Accepted Solution
Expert: Joe Winograd replied at 2024-07-30 21:14:39
250 points EXCELLENT
Our messages just crossed. See the code in my last post. I tested it and it works fine. But I had my own test folder in there (d: tempd est). Of course, change it to yours (c:data) — so you want:
Author: coerrace replied at 2024-07-30 21:12:03
joe winograd I used your line and appears is bad formatted say:
do was unexpected at this time and like that if you make work sure go to search in subdirectories? Looks great I changed the IN DO (.) by IN (.) DO and does more but I see not go to inside sub directories to conver the files the error say:
mogrify: unable to open image `*.pdf': Invalid argument @ error/blob.c/OpenBlob/
2587.
And that means is looking inside c:data but not inside the subdirectories could you check I like mogrify.
duncanb7 why you use the del command? if it is just convert? don't want to destroy any data is a server.
do was unexpected at this time and like that if you make work sure go to search in subdirectories? Looks great I changed the IN DO (.) by IN (.) DO and does more but I see not go to inside sub directories to conver the files the error say:
mogrify: unable to open image `*.pdf': Invalid argument @ error/blob.c/OpenBlob/
2587.
And that means is looking inside c:data but not inside the subdirectories could you check I like mogrify.
duncanb7 why you use the del command? if it is just convert? don't want to destroy any data is a server.
Expert: Joe Winograd replied at 2024-07-30 20:39:26
I should have mentioned that <mogrify.exe> is in the same ImageMagick install folder as <convert.exe>, but you probably figured that out already. :) However, the one-line code I posted is wrong. I'm very sorry about that — I feel really bad. Here's code that I just tested with mogrify and it works fine:
FOR /R "d: tempd est" %%I in (.) DO (
Pushd %%I
mogrify -format jpg *.pdf
Popd )
Once again, I apologize for the previous bad code. Regards, Joe
FOR /R "d: tempd est" %%I in (.) DO (
Pushd %%I
mogrify -format jpg *.pdf
Popd )
Once again, I apologize for the previous bad code. Regards, Joe
Expert: duncanb7 replied at 2024-07-30 20:35:50
try this code, do it in example files and directory first, it will work,
@echo offforfiles /p "c:data" /s /m *.pdf /C "cmd /c echo @path ">junk.txtfor /f "tokens=1 delims=." %%F in ('type junk.txt') do (convert %%F.pdf" %%F.jpg")del junk.txt 1:2:3:4:
Expert: Joe Winograd replied at 2024-07-30 20:35:27
You want the mogrify command, not convert, because mogrify accepts a wildcard. This command should do it for you:
Regards, Joe
Author: coerrace replied at 2024-07-30 20:24:29
not c: is c:data and inside c:data there are a lot of subdirectories the pdf "search" must be in all subdirectories inside c:data for example search in c:dataone in c:data wo and so on there are hundred of sub directories there, "one" and "two" are not real could be any name in that hundred of directories inside c:data
Thank you
Thank you
Expert: duncanb7 replied at 2024-07-30 20:15:36
So just, you mean that search pdf files at c: drive and convert it to jpg files and save them at the same location they are converted from.
Duncan
Duncan
Author: coerrace replied at 2024-07-30 20:10:27
well if the word search apply is search but for example when you use copy *.do c: it grab just the .doc files to c: but maybe is not a kind of search but if apply the word is ok. In what I need is for each subdirectory convert only the pdf files and convert to jpg and store in same sub directory where pdf is and the rest of other extensions must be ignored and on that way for all sub directories inside c:data
Thank you
Thank you
Expert: duncanb7 replied at 2024-07-30 19:57:33
you mean that search file and convert it to jpg file and put at the same location, right ?
Duncan
Duncan
Author: coerrace replied at 2024-07-30 19:54:44
I don't want to put the destination files in in one directory if you read the main topic I need the files converted in each sub directory by different for example:
a directory called "one" and another called "two"
inside "one" there are these pdf files: 1.pdf, 2.pdf and 3.pdf and the directory "two" has these pdf files other1.pdf and other2.pdf
These 2 directories are inside c:data and the batch must convert for example when pass to directory "one" convert the files 1.pdf, 2.pdf and 3.pdf to 1.jpg, 2.jpg and 3.jpg and store in the same "one" directory and when the script pass to directory "two" must convert the other1.pdf and other2.pdf to other1.jpg and other2.jpg and store inside same "two" directory not in other. If in "one and "two" directories there are .flv or any other extension different than pdf the script must ignore or not convert or touch the file.
This is an example but c:data could have hundred of directories not just "one" and "two" and all the files inside each sub directory must respect the location and must be together where the original pdf file reside but never throw in one directory all the conversion.
Any modification to do this in the main script I posted?
Thank you
a directory called "one" and another called "two"
inside "one" there are these pdf files: 1.pdf, 2.pdf and 3.pdf and the directory "two" has these pdf files other1.pdf and other2.pdf
These 2 directories are inside c:data and the batch must convert for example when pass to directory "one" convert the files 1.pdf, 2.pdf and 3.pdf to 1.jpg, 2.jpg and 3.jpg and store in the same "one" directory and when the script pass to directory "two" must convert the other1.pdf and other2.pdf to other1.jpg and other2.jpg and store inside same "two" directory not in other. If in "one and "two" directories there are .flv or any other extension different than pdf the script must ignore or not convert or touch the file.
This is an example but c:data could have hundred of directories not just "one" and "two" and all the files inside each sub directory must respect the location and must be together where the original pdf file reside but never throw in one directory all the conversion.
Any modification to do this in the main script I posted?
Thank you
Assisted Solution
Expert: duncanb7 replied at 2024-07-30 18:57:43
250 points EXCELLENT
Try this using forfile, window commnad, search all pdf at c: drive, and the read junk.txt file without its extension and convert it into jpg. All jpg files will be located the directory where this batch file you run, you can change it to other directory if need.
Duncan
Duncan
@echo offforfile /p "c:" /s /m *.pdf" >junk.textfor /f "tokens=1 delims=." %%F in ('type junk.txt') do (convert %%F.pdf" %%F.jpg")del junk.txt 1:2:3:4: