Hi
I'm writing a batch process to merge groups of tiffs into one pdf and I've got it working so that it can cre the file, and everything looks great. One last thing I'm trying to achieve and I can't seem to find it:
there are hundreds of thousands of files in random folders and I want to store them in a new folder structure. So instead of them all being in c:\nconvert\ they should be in subfolders like
c:\nconvert\AB\12345\
c:\nconvert\AB\22334\
c:\nconvert\AB\12233\
c:\nconvert\BG\12233\
c:\nconvert\FC\22334\
and so on. When I set the script to do this i get an error message saying it can't create the file, and I assume this is because it can't create the subdirectories.
Is there any way I can force it to create the folder if it doesn't exist in teh way that - say - xcopy can?
Hm... i suppose I could save it in a temp folder and use xcopy to move it on couldn't i... I might try that if all else fails but I hope it won't be needed!
Varying folder
Moderators: XnTriq, helmut, xnview
-
- Posts: 5
- Joined: Tue Nov 10, 2015 12:07 am
Re: Varying folder
Sample code for conversion of one file:
In this example,
NCONVERT_TEST is the main folder
SG\ and 560876\ are subfolders that don't exist yet and I need to create in the process of converting the file
Code: Select all
nconvert.exe -multi -out pdf -c 5 -dpi 72 -o "C:\Users\kewbsl\Desktop\NCONVERT_TEST\SG\560876\1016808_v1.pdf" "U:\07034000\07033640.tif" "U:\07034000\07033641.tif" "U:\07034000\07033642.tif" "U:\07034000\07033643.tif" "U:\07034000\07033644.tif" "U:\07034000\07033645.tif" "U:\07034000\07033646.tif" >>"C:\Users\kewbsl\Talend\Working Directory\output.txt"
NCONVERT_TEST is the main folder
SG\ and 560876\ are subfolders that don't exist yet and I need to create in the process of converting the file
-
- XnThusiast
- Posts: 4178
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Varying folder
In a quick test I just set up, an output folder that didn't exist was created when the script ran, so possibly you need to back up a bit...kewbsl wrote:I'm writing a batch process to merge groups of tiffs into one pdf and I've got it working so that it can create the file, and everything looks great. One last thing I'm trying to achieve and I can't seem to find it: there are hundreds of thousands of files in random folders and I want to store them in a new folder structure. So instead of them all being in c:\nconvert\ they should be in subfolders like:
c:\nconvert\AB\12345\
c:\nconvert\AB\22334\
c:\nconvert\AB\12233\
c:\nconvert\BG\12233\
c:\nconvert\FC\22334\
When I set the script to do this I get an error message saying it can't create the file, and I assume this is because it can't create the subdirectories...
I ran this code:
Code: Select all
nconvert -out tiff -o output\test.tiff test.jpg
I should explain that I normally run scripts as batch files .bat in a folder containing a copy of NConvert, as when I first started using the command line I found that was a simple way of ensuring the scripts ran...
Edit:
Have you tried running your code without this final section:
Code: Select all
>>"C:\Users\kewbsl\Talend\Working Directory\output.txt"
You do not have the required permissions to view the files attached to this post.
-
- Posts: 5
- Joined: Tue Nov 10, 2015 12:07 am
Re: Varying folder
Thanks. This is interesting. I have experimented a bit. It seems as though it only _doesn't_ work when i use -multi in the code. I can run a conversion in the format you use but as soon as I add one more file and put the -multi switch in there it breaks. Likewise, using -multi in a situation where the folder exists is fine, but where it doesn't it fails, so I think nConvert can't create folders in -multi mode.cday wrote:I ran this code:
Code: Select all
nconvert -out tiff -o output\test.tiff test.jpg
-
- XnThusiast
- Posts: 4178
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Varying folder
Confirmed in my tests:kewbsl wrote:It seems as though it only _doesn't_ work when I use -multi in the code. I can run a conversion in the format you use but as soon as I add one more file and put the -multi switch in there it breaks.
Likewise, using -multi in a situation where the folder exists is fine, but where it doesn't it fails, so I think NConvert can't create folders in -multi mode.
This code works and creates the required output folder:
Code: Select all
nconvert -out tiff -o output\test.tiff test.jpg
Code: Select all
nconvert -multi -out pdf -o test.pdf test_1.jpg test_2.jpg
Code: Select all
nconvert -multi -out pdf -o output\test.pdf test_1.jpg test_2.jpg
Returning to your overall problem, you need to convert hundreds of thousands of TIFFs in a way you haven't fully outlined, but earlier you mentioned the possibility of creating a temporary folder to hold the output files and then using XCOPY to create the associated output folder when required.
Without knowing exactly how you propose to proceed, I wondered if using MD in your script might be more direct, as in this batch file .bat :
Code: Select all
MD output
nconvert -multi -out pdf -o output\test.pdf test_1.jpg test_2.jpg
You could also, of course, use SET to define a variable or variables to possibly make it easier to reuse code repeatedly with different parameter(s) that only need to be entered once.
-
- Posts: 5
- Joined: Tue Nov 10, 2015 12:07 am
Re: Varying folder
Thanks - I thought of something similar, but there could be several files all in the newly created folder, so the subsequent statements would cause errors unless i did some sort of check to see if it was there already, which would get a bit complicated. I guess it's another option though. It'll give me a lot of errors in the output log but at least it'll be quicker than moving a file from one place to another and deleting the temp file, I should think... Hm. Thanks very much for your expert input and yes, I'll submit the issue on its own thread as a possible bug report.cday wrote: Without knowing exactly how you propose to proceed, I wondered if using MD in your script might be more direct, as in this batch file .bat :
That code runs and creates the required output folder just before it is needed...Code: Select all
MD output nconvert -multi -out pdf -o output\test.pdf test_1.jpg test_2.jpg
You could also, of course, use SET to define a variable or variables to possibly make it easier to reuse code repeatedly with different parameter(s) that only need to be entered once.
-
- Posts: 5
- Joined: Tue Nov 10, 2015 12:07 am
Re: Varying folder
I see you've done that too. Now that's what I call service!kewbsl wrote: yes, I'll submit the issue on its own thread as a possible bug report.