troubleshooting Question

DOS : "For %i IN (*.txt)..."

Avatar of silchester
silchester asked on
Microsoft DOS
5 Comments1 Solution1512 ViewsLast Modified:
Hi
I am trying to use the DOS FOR command to apply the 7zip compression tool to each individual file within a directory.

FOR %i IN (*.txt) DO 7z a %i.zip %i

Now, the compression is fine, but my problem is that %i returns filenames such as "h1.txt","h2.txt" etc. For reasons that I will not go in to, I need to parse the %i so that I end up with just "h1","h2" etc - ie get rid of the ".txt" bit.

I have been trying to use the same trick I saw on this site for the date ie %date:~6,4% to no avail.

Any ideas?
Cheers
Neil
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros