1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't do something to a file and then delete it?

Discussion in 'Support' started by pb4072, Mar 25, 2016.

  1. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Below is part of a .btm script I've written. It's a graphic function. I need to act on PDFs in a directory. Then, I need to move them to a subdirectory. The first part is working, but, it's not moving the file. And, that's really not good, because, then, it'll just continue to act on the same files.

    I know nothing about TCC variables. The documentation just confuses the hell out of me. In the shell I saw that I could create the variable MPCFILE using the "for" command. I have no idea about what more to do with this. I've tried this with a closing percentage sign around the variable, too, but, I get the same results.

    cd \workflows\filetrain\00120-mcardlepdfs\
    for %%I in (*.pdf) do set MPCFILE = %%I
    E:\apps\callas\cli\pdftoolbox.exe -o=F:\workflows\filetrain\00120-McArdlePDFs\success\%MPCFILE E:\pdftoolboxprofiles\convert_to_grayscale_v7.3.kfpx --overwrite %MPCFILE && move %MPCFILE \workflows\filetrain\00120-mcardlepdfs\processed


    Thanks!
    Peter
     
  2. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Sorry. My discussion title should read "Can't do something to a file and then move it?," not delete it.
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,079
    Likes Received:
    30
    I'm not sure that script does what you want, or think. The line
    Code:
    for %%I in (*.pdf) do set MPCFILE = %%I
    stands alone. If you have 1.pdf, 2.pdf, and 3.pdf, it will do
    Code:
    set MPCFILE=1.pdf
    set MPCFILE=2.pdf
    set MPCFILE=3.pdf
    At this point MPCFILE will be "3.pdf". The script will continue and only 3.pdf will be processed.
    If you really want to process all of *.pdf, try something like
    Code:
    do MPCFILE in *.pdf
       E:\apps\callas\cli\pdftoolbox.exe -o=F:\workflows\filetrain\00120-McArdlePDFs\success\%MPCFILE
       E:\pdftoolboxprofiles\convert_to_grayscale_v7.3.kfpx --overwrite %MPCFILE && move %MPCFILE \workflows\filetrain\00120-mcardlepdf\processed
    enddo
     
  4. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Thanks. Well, I never know how many PDFs I have in there. There could be anywhere from 1 to 100 files. I'll try this with "do," though.
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,079
    Likes Received:
    30
    However many there are, your original code would only process the last one. DO should work better; it's meant for multiple-line loops which is, it seems, what you want.
     
  6. pb4072

    Joined:
    Jul 25, 2008
    Messages:
    33
    Likes Received:
    0
    Yeh. "do" worked. Thanks a lot. But, I needed to do real work here, so, I couldn't wait. I just used cmd.exe. I have to say. TCC is cool and powerful, but, I don't have the patience to read through all the doc, which isn't very good, in my opinion. Thanks again.
     
  7. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,040
    Likes Received:
    84
    That statement is a bit puzzling to me, on several counts.
    1. You had a response (and a fix for your batch file) two hours after you posted it.
    2. If you wanted a faster response, if you had run your batch file in the Take Command batch debugger, you would have discovered the problem in a minute or two.
    3. CMD.EXE also wouldn't work with the FOR syntax you were using.
    4. I agree that if you don't want to learn a language by reading the docs, you probably shouldn't be using it. This is not unique to the TCC scripting language.
     
    Glenn Bowes and Charles G like this.

Share This Page