Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch file 1

Status
Not open for further replies.

Zygor

Technical User
Apr 18, 2001
271
US
Can anyone point me to the right forum.

I have a need for a .bat file to open Access only after it does something like the following.


for %%c in (e:\new folder\*.txt) do if not %%c == "e:\new folder\My New Text Document.txt" del %%c


It's that line I need help with
 
From my rather rusty batch file experience, can I just confirm that you want to delete all files except e:\new folder\My New Text Document.txt by looping through the .txt files.

To be honest I'd do something like:
IF EXIST "E:\New Folder\My New Text Document.txt" ren "e:\new folder\my new text document.txt" $£(£spdf.asd

if exist e:\new folder\*.txt del e:\new folder\*.txt

ren e:\new folder\$£(£spdf.asd "my new text document.txt"

so you've just changed its name to something unusual, deleted all .txt files from that folder, then renamed it back.

To open Access from a batch file, just run the Access executable for your version. To open a specific database, use "Start <path to MDB file>"

John


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top