A tech-savvy individual would no doubt have already known that batch scripts are a fast and easy way to automate mundane, everyday tasks. Today I will show you how to make a batch script that will generate a directory tree.
A directory tree is a way to graphically display the folder structure of a drive or path, which will be represented via text and ASCII characters.
1. The Notepad
Open up a text editor. Your standard run-of-the-mill default Notepad will do you just fine, but I highly suggest you install its more useful and coding-friendly counterpart: Notepad++.
2. The Code
Next, copy and paste the following line of code:
@echo off
echo Generating Anime Tree Directory Listing...
echo Please Wait...
cmd /c tree /f /a >Anime.txt
Then, save the file. Your file should now look like this:
3. The Batch Script
Lastly, you have to change the file extension from *.txt to *.bat for the batch script to run properly. After that is done, place your batch script inside the directory of your choice and double click to run the script. Depending on several factors such as the drive size and the number of folders/files that are held within the drive, it'll take you between a few seconds to a few minutes.
The final result will output a text file labeled "Anime.txt". Within it contains every folder/file in your directory, and when you have a very large and extensive (we're talking about 1TB+) anime collection, then this is almost like a godsend. Finding and cataloging your archives become much, much easier from now on. It's also very useful when you have friends who share your interest of anime and who are collectors themselves. You could share the directory list you generated from your batch scripts with your friends and also get theirs as well to see what files could be exchanged.
*NOTE* The batch script will only list the folders/files in the GIVEN directory i.e. if you place the batch script in the directory "C:/Anime", it will list only the folders/files inside the folder labeled "Anime". If you want a complete listing of every directory and sub-directory in your drive, then place and run the batch script in your root drive i.e. "C:".
4. Forks and deviations
By playing around with the script, you can change the results of the directory listing. Here is one example:
@echo off
echo Generating Anime Tree Directory Listing...
echo Please Wait...
SET Choice=
SET /P Choice=Press enter to start.
IF "%Choice%"=="" GOTO Start
:Start
cmd /c tree /f /a >Anime.txt
The main difference between this one and the previous one is that it will ask you for a confirmation to run the script by pressing "Enter", whereas the previous one will run automatically. Just something to mix it up a bit, but I'm sure some of you will find it useful, no doubt.
And without further ado, this guide comes to a close.
Below are some download links to copies of my batch script and also some websites for further reading if you're interested.
Anime Tree Directory.bat
http://www.mediafire.com/?a69hhhm1h7j2hlt
Anime Tree Directory_Press Start.bat
http://www.mediafire.com/?bnilbkslcw5nge5
Sources/References:
http://www.ericphelps.com/batch/
http://ss64.com/nt/
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/batch.mspx?mfr=true
http://commandwindows.com/batch.htm
http://www.computerhope.com/batch.htm
No comments:
Post a Comment