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

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

May 20, 2008
Syracuse, NY, USA
I'm not sure that script does what you want, or think. The line
for %%I in (*.pdf) do set MPCFILE = %%I
stands alone. If you have 1.pdf, 2.pdf, and 3.pdf, it will do
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
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
May 20, 2008
Syracuse, NY, USA
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.
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.
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.


Staff member
May 14, 2008
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.

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.
Similar threads
Thread starter Title Forum Replies Date
vefatica Append something entered to a file? Support 12
vefatica @EXECSTR ... TCSTART ... something's wrong! Support 7
vefatica Something got very slow (very recently) Support 1
L How to? Shebang, nice idea but am I missing something? Support 4
vefatica Something is hosed in build 74 Support 10
M Hotkey-mechanism, for doing something with the current command-line Support 4
M Yet another strange something re something called "@TCONVERT" Support 8
vefatica Something wrong with @PID Support 10
M Is this a restriction I wasn't aware of or something new (that maybe shouldn't be there)? Support 16
M Something that does not seem possible... Support 2
A Can you set an image file 'tag' with TCC/4NT? Support 0
old coot File create date/time is sticky across file deletion. Support 9
J History file load hangs if file has complete garbage in it... Support 1
jdanielp Cannot step into and/or call another .bat file when debugging .bat file Support 2
thorntonpg file explorer - short cut keys Support 1
JohnQSmith New online help file wrong logo Support 7
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
samintz How to? swap endianness in a binary file Support 12
vefatica `Back quotes` - command line vs. batch file Support 5
fpefpe How to? batch file size Support 2
Jay Sage Issues With TCMD File Explorer Support 0
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
Joe Caverly @FILESIZE and NTFS File Stream Support 1
Joe Caverly Embedding an .EXE (or other file) into a .BTM Support 8
U Command help on file names Support 5
S Concatenate all playlists into 1 file Support 22
Joe Caverly Set a batch variable (%1 - %n) when TCC is executing a batch file Support 5
Joe Caverly Rename file that begins with Emoji Support 7
Joe Caverly PSHELL and NTFS File Streams Support 2
P Kill all other instances of tcc from a btm batch file Support 2
D ffind hangs on large file Support 18
Alpengreis Documentation Minor issue in help file for view /E Support 1
fpefpe batch file ending early Support 18
J Licesne file location Support 1
K robocopy cancelling batch file processing Support 28
Jay Sage TCMD Crashes with "tctoolbar /c /r file" Support 5
A Unable to pass batch file arguments unaltered Support 18
MikeBaas How to...extract a string from a .json-file? Support 10
vefatica LIBRARY and file name completion? Support 4
D What does the file "..\Everything\Run history.csv" store? Support 5
H Takecommand.pdf failed not a pdf file Support 6
Joe Caverly DIRectory Colorization in v25 Help File Support 0
C show file description? with dir? Support 8
D When copying/moving, appending " (2)" to filename when the target file already exist. Support 7
R How to? Dir specific file search patterns with spaces in the pathnames? Support 6
Joe Caverly _EXPANSION in help file Support 0
Stefan Hassel Installation file TC 24.02 Build 47 is actually version 25.00.1 Support 10
vefatica Are @FILEDATE[file] and @FILEDATE[file,u] ever different? Support 2
K_Meinhard Help file error Support 1
Joe Caverly JOBMONITOR in Help File Support 1

Similar threads