User User name Password  
   
Tuesday 26.11.2024 / 23:48
Search AfterDawn Forums:        In English   Suomeksi   På svenska
afterdawn.com > forums > software, operating systems and more > windows - general discussion > help with a simple batch file
Show topics
 
Forums
Forums
Help with a simple batch file
  Jump to:
 
Posted Message
klassic
Member
_
10. January 2008 @ 10:42 _ Link to this message    Send private message to this user   
I set up a simple batch file in windows to create a file that lists the names of all files in a folder. I added it to the action list for folders so I can run this on any folder at any time. Here is the code from my batch file:


@echo off 

dir %1 /-p /b /o:gn >File-List.txt
exit

Is there any way that I can add the folder name to the beginning of the created file name? IE if I run this on a folder "Downloads" the resulting file name would be "Downloads-File-List.txt"

I use this forum for everything else, so I hope someone can help. Or if someone knows a better forum to post this type of question please let me know.

I wanna devise a virus and bring dire straights to your environments. Crush your corporations with a mild touch, trash the whole computer systems and revert you to papyrus - Deltron 3030
Advertisement
_
__
Junior Member
_
10. January 2008 @ 12:58 _ Link to this message    Send private message to this user   
I'm no expert but I don't think it's possible to do what you want with a simple batch file, it'll probably require writing a vb script.
varnull
Suspended permanently
_
10. January 2008 @ 13:42 _ Link to this message    Send private message to this user   
It's easy but I can't remember exactly how.. you need to get the directory name, and assign it to $dir_name.. then cd to the working directory, run your batchfile and output >$dir_name File-List.txt

or have I got confused with C++ ?? It's been a really long time since I did and dos batchfile stuff... There are books and guides all over the place about dos batchfile functions.. I do know you don't need anything like visual basic to do this... because we were doing it long before there was such a thing.


Junior Member
_
10. January 2008 @ 15:32 _ Link to this message    Send private message to this user   
Quote:
I do know you don't need anything like visual basic to do this... because we were doing it long before there was such a thing.
The challenge though is that he added it to his "action menu" which I believe he means when he right clicks on a folder he wants to run it from there. Last I remembered there wasn't too much right clicking going on in DOS
klassic
Member
_
10. January 2008 @ 15:53 _ Link to this message    Send private message to this user   
I am trying to do this by just running the batch file. I am assuming that any dos commands would just need to be added to this .bat file. I only added it to the action menu to make it simpler.

I wanna devise a virus and bring dire straights to your environments. Crush your corporations with a mild touch, trash the whole computer systems and revert you to papyrus - Deltron 3030
Member
_
10. January 2008 @ 18:27 _ Link to this message    Send private message to this user   
You can use the variable %CD% to get the current path.

http://www.jsifaq.com/SF/Tips/Tip.aspx?id=8782


Advertisement
_
__
 
_
klassic
Member
_
16. January 2008 @ 12:12 _ Link to this message    Send private message to this user   
Thanks seb32! That link and another tip on that site got me part of the way. I started tweaking some of the code they had and figured out that it was easier than I thought. All I had to do was replace File-List with %1 and it worked. Here is the new code.

@echo off 

dir %1 /-p /b /o:gn >%1%.txt
exit


Now all I have to do is right click on a folder and use the action, "Create File List", that I created and I get a .txt file that lists all the files that are in that folder.

Man, I love this site. Even if you don't get the exact answer you need someone is bound to get you close. Thanks again everyone who replied, and everyone who ever has helped someone on this site.

I wanna devise a virus and bring dire straights to your environments. Crush your corporations with a mild touch, trash the whole computer systems and revert you to papyrus - Deltron 3030
afterdawn.com > forums > software, operating systems and more > windows - general discussion > help with a simple batch file
 

Digital video: AfterDawn.com | AfterDawn Forums
Music: MP3Lizard.com
Gaming: Blasteroids.com | Blasteroids Forums | Compare game prices
Software: Software downloads
Blogs: User profile pages
RSS feeds: AfterDawn.com News | Software updates | AfterDawn Forums
International: AfterDawn in Finnish | AfterDawn in Swedish | AfterDawn in Norwegian | download.fi
Navigate: Search | Site map
About us: About AfterDawn Ltd | Advertise on our sites | Rules, Restrictions, Legal disclaimer & Privacy policy
Contact us: Send feedback | Contact our media sales team
 
  © 1999-2024 by AfterDawn Ltd.

  IDG TechNetwork