Command help on file names

Sep 30, 2016

I knew that years ago I’ve already used it but now I can’t get it up running …
I want a TCC command running on several jpg’s and the output should consider only the file name and not the extension.

I’ve tried this without success:

for %a in (St-Tropez-1984*.jpg) do cwebp -q 80 %a -o %@name[%file].webp

E.g. one file name is St-Tropez-1984_1280w.jpg and the output name should be St-Tropez-1984_1280w.webp.
If I’m just using %a.webp for the output the “.jpg” part isn’t discarded and I got file names like St-Tropez-1984_1280w.jpg.webp.

Thanks in advance.
Dec 10, 2014
You're using %a and then another var in %@name[%file]?

If you're not wild about 1-line shell scripts try to write a quick .btm for better debugging, you can echo the vars or use the tcc debugger ...

do imgin in /a:-d St-Tropez-1984*.jpg
set imgout=%@name[%imgin].webp
cwebp %imgin -o %imgout
if not isfile %imgout .or. %? ne 0 echo error!

... you might have to work around special chars with setdos /x
Sep 30, 2016
I will try your BTM, thank you (I don't understand everything now).
My goal is to separate the file name and extension and process the file(s) so that the CWEBP program can add its webp extension but take the jpg extension for input. If it works then I could write a BTM that does the command on all jpegs in a folder and process them to webp.
Sep 30, 2016
The BTM works very well, thank you!
What I do not understand is the switch "/a:-d". Is this an attribute selection with directories? And why is this needed?
Ah, and now thanks to your BTM I got my one-liner working:
for %a in (*.jpg) do cwebp -q 80 %a -o %@name[%a].webp
This will convert every JPG file to WEBP.
Thanks again.

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
The BTM works very well, thank you!
What I do not understand is the switch "/a:-d". Is this an attribute selection with directories? And why is this needed?
He's excluding directories. DO, by default, returns both files and directories. DO /A:-D returns only files. DO /A:D (without the minus) would return only directories, not files.

In fact it's unlikely that you have any subdirectories that would match that wildcard pattern. Juppy is being professional here: considering the unlikely, and checking for errors.
Sep 30, 2016
Thank you very much for the explanation. I did read the help file but somehow missed the little "-" and wondered why an attribute "directory" is needed ...
Similar threads
Thread starter Title Forum Replies Date
samintz How to? Search for %(command) in Help? Support 1
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
R wmic command help Support 9
Joe Caverly 7zip command links to zip help Support 0
R Documentation Help for SHIFT Command Support 4
S Documentation HELP Nit - Index - Desktop command Support 0
M Web Help option in Take Command 15 broken? Support 3
rconn News Take Command Web Help Updated Support 0
Dan Glynhampton Documentation v15 help: Help for SCREENMONITOR command Support 0
Frank Problem with Window "Take Command Help" Support 3
D Help mentions Take Command LE Support 0
dcantor Documentation Help error for command LOG Support 0 Inadequate HELP for UNZIP command. Support 3
S HELP issue: ON command Support 2
D Can alias pass parameters to for command? Support 3
T VIEW only works from command line Support 14
rconn News Take Command / TCC / CMDebug / TCC-RT v28 Released Support 0
T Take Command 28: Lua reports version 5.4.0 (5.4.3 expected) Support 0
Jay Sage WAD Possible Bug With OPTION Command With @FILE Support 5
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.24 uploaded Support 0
J Take command does not start on Windows 10 Support 3
vefatica `Back quotes` - command line vs. batch file Support 5
Jay Sage WAD Failure of Alias Command with /Z Option Support 14
Phileosophos Is there any way to open the Take Command options dialog from the command line? Support 8
Phileosophos Command-line Editing Shortkeys That Fail Support 6
fpefpe How to? free (internal) command Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.01.23 uploaded Support 0
T How to? retain command history across reboot? Support 6
rconn News Take Command / TCC / CMDebug / TCC-RT v27.01 Build 22 Uploaded Support 0
Jay Sage Bug With Flow Control and/or Command Grouping Support 2
GermanDirk How to? EVENTLOG Command with simple User Rights not functional Support 4
Jay Sage Take Command Is Too Fast! Support 4
Jay Sage Comparison of IF with Command Group and IFF Support 6
D Open Windows 10 Photos app from command line Support 11
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.21 uploaded Support 0
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.20 uploaded Support 0
U Can not get/start Take Command gui Support 1
rconn News Take Command / TCC / CMDebug / TCC-RT 27.0.19 Support 0
S Increasing Font Point Size in Command Tabs Support 2
mfarah Fixed The DATE command produces the wrong error message. Support 1
vefatica Command name mix-up Support 3
FreezerBurnt "Missing SETLOCAL" when initializing Visual Studio Command Prompt. Support 9
E How to? Closing desktop created by DESKTOP command Support 10
rconn News Take Command / TCC / CMDebug / TCC-RT v27.0.18 Support 0
K Take Command fox XP? Support 7
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
fpefpe How to? command echo in title line/bar Support 2
vefatica Command line DO with no closing parenthesis? Support 9
vefatica Command history search is off Support 7
H How to? How can I say "if the command separator is not ~ then setdos /C~" Support 8

Similar threads