Mourning the loss of our friend, WhitPhil.
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 audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel excel 2003 firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem recovery router safe mode screen slow sound spyware tdlwsp.dll trojan vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > All Other Software >
Solved: Batch File - Dir switches

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
Slimboy Fat's Avatar
Senior Member with 128 posts.
 
Join Date: Oct 2004
Experience: Intermediate
03-Nov-2009, 10: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
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
03-Nov-2009, 11:00 AM #2
Code:
FOR /F "tokens=*" %%A IN ('dir /b /a-d *.jpg') DO (
 echo %%~nA>>filelist.txt
 )
Slimboy Fat's Avatar
Senior Member with 128 posts.
 
Join Date: Oct 2004
Experience: Intermediate
03-Nov-2009, 11:12 AM #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
Distinguished Member with 14,983 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
03-Nov-2009, 11:19 AM #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
Senior Member with 128 posts.
 
Join Date: Oct 2004
Experience: Intermediate
03-Nov-2009, 11:35 AM #5
Thats worked spot on.

Thanks a lot.
Reply Bookmark and Share

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 01:51 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.