There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
All Other Software
Tag Cloud
access acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming google gpu hard drive hardware hdmi internet laptop malware memory missing monitor motherboard network operating system printer problem ram registry router slow software sound trojan ubuntu 11.10 uninstall usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > All Other Software >
Solved: Batch File - Dir switches

Reply  
Thread Tools
Slimboy Fat's Avatar
Member with 142 posts.
 
Join Date: Oct 2004
Experience: Intermediate
03-Nov-2009, 11:51 AM #1
Solved: Batch File - Dir switches
Hello,

Already have a batch file that saves a list of the files in a certain folder into a text file.

I am using the the /B and /D switches as well as a *.jpg wildcard to create a clean, files only list showing only the jpg files. What I need now is a switch to remove the .jpg extension from the text file (not from files themselves).

example...
abcdef.jpg will be shown in the txt file as abcdef.

TIA
SBF
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
03-Nov-2009, 12:00 PM #2
Code:
FOR /F "tokens=*" %%A IN ('dir /b /a-d *.jpg') DO (
 echo %%~nA>>filelist.txt
 )
Slimboy Fat's Avatar
Member with 142 posts.
 
Join Date: Oct 2004
Experience: Intermediate
03-Nov-2009, 12:12 PM #3
Hi,

Thanks for the reply but I'm not that bright when it comes to batch files. I currently have the following...

Code:
dir "F:\Images\*.jpg" /B /D > "F:\Images\List.txt"
How would I implement this into your code.


Thanks
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
03-Nov-2009, 12:19 PM #4
You don't need the /D swtich.
Code:
FOR /F "tokens=*" %%A IN ('dir /b /a-d "F:\Images\*.jpg"') DO (
 echo %%~nA >>"F:\Images\List.txt"
 )
Slimboy Fat's Avatar
Member with 142 posts.
 
Join Date: Oct 2004
Experience: Intermediate
03-Nov-2009, 12:35 PM #5
Thats worked spot on.

Thanks a lot.
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:45 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.