

InterviewSolution
Saved Bookmarks
1. |
Solve : How to create .bat files which create filelistings? |
Answer» <html><body><p>Hi, <br/><br/>I've got no experience with batch files to speak of and want to create batch files which list the contents of my folders. I've been looking around and found d quite a few examples, some of which I tried with (some) success...I found that some different commands seem to give the same result, and others I recombined which then didn't work the way intended. So I now want to make a list with most or all the relevant commands (\a, \b and so on) and their values or results. I also would like to know if they are freely combinable or not. I've been searching the web but only come up with (sometimes conflicting) bits and pieces and would appreciate any kind of help. Are there any e-books on the subject or is anyone willing to tell me a bit? <br/><br/>I'm not familiar with DOS or anything, only use Windows and other progs. But I know how to install OS and arm PCs and stuff like that...<br/><br/>Thanks a lot in advance!Use only one \\ where two appear<br/><br/>C:\\test>type ch88.bat<br/><br/>echo off<br/><br/>dir *.* %1<br/><br/>Output:<br/><br/>C:\\test>ch88.bat c:\\test <br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\\test<br/><br/>08/08/2010 05:24 PM .<br/>08/08/2010 05:24 PM ..<br/>05/27/2010 07:21 PM !Grants<br/>07/08/2010 02:58 PM 8 07072010timeclock.csv<br/>07/08/2010 02:58 PM 8 07082010timeclock.csv<br/>07/25/2010 04:43 PM 14 1.txt<br/>07/25/2010 04:44 PM 14 10.txt<br/>07/25/2010 04:46 PM 14 11.txt<br/>07/25/2010 04:46 PM 14 12.txt<br/>07/25/2010 04:46 PM 14 13.txt<br/>07/25/2010 04:47 PM 14 14.txt<br/>07/25/2010 04:47 PM 14 15.txt<br/>. <br/>.<br/>.Thanks a lot, Victoria<br/><br/>Couldn't do much with it, though...don't understand enough.<br/>I'll post some of the info I have to let you know what it is I'm after:<br/><br/><br/>A list of commands I'd like to complete as much as possible (and, of course, check for errors):<br/><br/>/a = read ALL files in folder (a = archivable files)<br/>:d = directories only<br/>-d = don't list the archive date/time<br/>/s = include files from sub-folders<br/>/b = exclude unnecessary file information such as filesize and stuff (b = bare names only)<br/>> = go to the following folder (sends the output to a file instead of displaying it on the screen)<br/>"...." = direction of folder to use<br/>\.mp3 = only list .mp3 files (exclusive command for type of files to list)<br/>:gen = generate <br/><br/><br/><br/>And some of the examples I have gathered and tried (but not all successfully):<br/><br/>dir /a /s /-p /o:gen >filelisting.txt<br/><br/>dir /a /b /s /-p /o:gen >filelisting.txt<br/><br/>dir /a /b /s /-p /o:gen >C:\Temp\filelisting.txt<br/>start notepad C:\Temp\filelisting.txt<br/><br/><br/><br/>So, what I wanted was to print a list of all my musicfiles - some 40.000 spread over Alphabetical folders with subfolders for groups and sub-subfolders for their discs. I've managed that, but wanted to clean up the process so I only get the archives names without all the other info (like timestamps and so on)...<br/><br/>Then I wanted to make that command part of the Explorer Context Menu (in Win7 apparently you need programs for that, I tried Context Menu Editor but it doesn't quite work - maybe it's not 64-bit compatible or maybe I need to do sth. differently) so that I can right-click over any folder and have it's contentslist saved in a dedicated folder - and open automatically afterwards... <br/><br/>But, although I'd appreciate a working commandline(s) for that purpose, I now also would like to understand the whole thing a bit better - that's why I'd like a list of commands and so on. Maybe I'm a bit over the top with that one - or it's just not as simple a matter as I imagine it to be and requires proper study. But, anyway....<br/><br/>Thanks a lot again<br/><a href="http://www.robvanderwoude.com/batchcommands.php">http://www.robvanderwoude.com/batchcommands.php</a><br/><br/><br/><br/>C:\\>dir /?<br/>Displays a list of files and subdirectories in a directory.<br/><br/> /A Displays files with specified attributes.<br/> attributes D Directories R Read-only files<br/> H Hidden files A Files ready for archiving<br/> S System files I Not content indexed files<br/> L Reparse Points - Prefix meaning not<br/> /B Uses bare format (no heading information or summary).<br/> /C Display the thousand separator in file sizes. This is the<br/> default. Use /-C to disable display of separator.<br/> /D Same as wide but files are list sorted by column.<br/> /L Uses lowercase.<br/> /N New long list format where filenames are on the far right.<br/> /O List by files in sorted order.<br/> sortorder N By name (alphabetic) S By size (<a href="https://interviewquestions.tuteehub.com/tag/smallest-646176" style="font-weight:bold;" target="_blank" title="Click to know more about SMALLEST">SMALLEST</a> first)<br/> E By extension (alphabetic) D By date/time (oldest first)<br/> G Group directories first - Prefix to reverse order<br/>Press any key to continue . . .<br/><br/><br/><br/>C:\\>dir /AD /w<br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\\<br/><br/>[$Recycle.Bin] [06-07-2010] [1] [1100] [20100419]<br/>[backup] [BILL-PC] [bin] [destfiles] [Documents and Settings]<br/>[LaserJet517] [logs] [MSOCache] [Office2003SP3Changes] [PerfLogs]<br/>[prison] [<a href="https://interviewquestions.tuteehub.com/tag/program-246414" style="font-weight:bold;" target="_blank" title="Click to know more about PROGRAM">PROGRAM</a> Files] [ProgramData] [RECENTBKUP] [Recovery]<br/>[System Volume Information] [temp] [test] [tmp] [Users]<br/>[Windows] [zz]<br/> 0 File(s) 0 bytes<br/> 27 Dir(s) 293,475,434,496 bytes free<br/><br/>C:\\><br/><br/>google .wav extention<br/>C:\\>dir /s *.wav | more<br/> Volume in drive C has no label.<br/> Volume Serial Number is 0652-E41D<br/><br/> Directory of C:\\Program Files\\Microsoft Office\\MEDIA\\CAGCAT10<br/><br/>03/10/1998 09:02 PM 22,618 ELPHRG01.WAV<br/>02/16/1999 09:50 PM 26,810 J0214098.WAV<br/> 2 File(s) 49,428 bytes<br/><br/> Directory of C:\\Program Files\\Microsoft Office\\OFFICE11<br/><br/>02/19/2003 01:05 PM 108,800 REMINDER.WAV<br/> 1 File(s) 108,800 bytes<br/><br/> Directory of C:\\Windows\\Installer\\$PatchCache$\\Managed\\9040211900063D11C<br/><br/>02/19/2003 01:05 PM 108,800 REMINDER.WAV<br/> 1 File(s) 108,800 bytes<br/><br/> Directory of C:\\Windows\\Media<br/><br/>06/10/2009 04:22 PM 216,364 chimes.wav<br/>06/10/2009 04:22 PM 113,964 chord.wav<br/>06/10/2009 04:22 PM 70,060 ding.wav<br/>06/10/2009 04:24 PM 118,060 ir_begin.wav<br/>06/10/2009 04:24 PM 126,252 ir_end.wav<br/>06/10/2009 04:24 PM 178,732 ir_inter.wav<br/>06/10/2009 04:22 PM 228,396 notify.wav<br/>06/10/2009 04:22 PM 111,788 recycle.wav<br/>06/10/2009 04:22 PM 88,236 ringout.wav<br/>06/10/2009 04:37 PM 153,644 Speech Disambiguation.wav<br/>06/10/2009 04:37 PM 71,212 Speech Misrecognition.wav<br/>06/10/2009 04:37 PM 188,460 Speech Off.wav<br/>06/10/2009 04:37 PM 147,500 Speech On.wav<br/>06/10/2009 04:37 PM 128,812 Speech Sleep.wav<br/>06/10/2009 04:22 PM 285,228 tada.wav<br/>06/10/2009 04:22 PM 178,220 Windows Balloon.wavHey, <br/>Thanks a lot, Victoria, for your help!<br/>I'll need to get some sleep now - gotta organize my employees tomorrow early on - but will follow up all your info as soon as I can.<br/>I'll post another reply after to let you know! <br/><br/>ManasaOK, Victoria - <br/><br/>I'm still quite busy with work and stuff - so I haven't tried anything yet. But your list has been usefull, as well as the link you posted. I think that I will simply have to get some e-book or tutorial and learn the stuff from scratch. <br/>Given that I started something (albeit nothing important, really) I just don't like not understanding what I'm doing.<br/><br/>Thanks again for your help<br/>C:>help<br/>For more information on a specific command, type HELP command-name<br/>ASSOC Displays or modifies file extension associations.<br/>ATTRIB Displays or changes file attributes.<br/>BREAK Sets or clears extended CTRL+C checking.<br/>BCDEDIT Sets properties in boot database to control boot loading.<br/>CACLS Displays or modifies access control lists (ACLs) of files.<br/>CALL Calls one batch program from another.<br/>CD Displays the name of or changes the current directory.<br/>CHCP Displays or sets the active code <a href="https://interviewquestions.tuteehub.com/tag/page-25452" style="font-weight:bold;" target="_blank" title="Click to know more about PAGE">PAGE</a> number.<br/>CHDIR Displays the name of or changes the current directory.<br/>CHKDSK Checks a disk and displays a status report.<br/>CHKNTFS Displays or modifies the checking of disk at boot time.<br/>CLS Clears the screen.<br/>CMD Starts a new instance of the Windows command interpreter.<br/>COLOR Sets the default console foreground and background colors.<br/>COMP Compares the contents of two files or sets of files.<br/>COMPACT Displays or alters the compression of files on NTFS partitions.<br/>CONVERT Converts FAT volumes to NTFS. You cannot convert the<br/> current drive.<br/>COPY Copies one or more files to another location.<br/>DATE Displays or sets the date.<br/>DEL Deletes one or more files.<br/>DIR Displays a list of files and subdirectories in a directory.<br/>DISKCOMP Compares the contents of two floppy disks.<br/>DISKCOPY Copies the contents of one floppy disk to another.<br/>DISKPART Displays or configures Disk Partition properties.<br/>DOSKEY Edits command <a href="https://interviewquestions.tuteehub.com/tag/lines-240113" style="font-weight:bold;" target="_blank" title="Click to know more about LINES">LINES</a>, recalls Windows commands, and<br/> creates macros.<br/>DRIVERQUERY Displays current device driver status and properties.<br/>ECHO Displays messages, or turns command echoing on or off.<br/>ENDLOCAL Ends localization of environment changes in a batch file.<br/>ERASE Deletes one or more files.<br/>EXIT Quits the CMD.EXE program (command interpreter).<br/>FC Compares two files or sets of files, and displays the<br/> differences between them.<br/>FIND Searches for a text string in a file or files.<br/>FINDSTR Searches for strings in files.<br/>FOR Runs a specified command for each file in a set of files.<br/>FORMAT Formats a disk for use with Windows.<br/>FSUTIL Displays or configures the file system properties.<br/>FTYPE Displays or modifies file types used in file extension<br/> associations.<br/>GOTO Directs the Windows command interpreter to a labeled line in<br/> a batch program.<br/>GPRESULT Displays Group Policy information for machine or user.<br/>GRAFTABL Enables Windows to display an extended character set in<br/> graphics mode.<br/>HELP Provides Help information for Windows commands.<br/>ICACLS Display, modify, backup, or restore ACLs for files and<br/> directories.<br/>IF Performs conditional processing in batch programs.<br/>LABEL Creates, changes, or deletes the volume label of a disk.<br/>MD Creates a directory.<br/>MKDIR Creates a directory.<br/>MKLINK Creates Symbolic Links and Hard Links<br/>MODE Configures a system device.<br/>MORE Displays output one screen at a time.<br/>MOVE Moves one or more files from one directory to another<br/> directory.<br/>OPENFILES Displays files opened by remote users for a file share.<br/>PATH Displays or sets a search path for executable files.<br/>PAUSE Suspends processing of a batch file and displays a message.<br/>POPD Restores the previous value of the current directory saved by<br/> PUSHD.<br/>PRINT Prints a text file.<br/>PROMPT Changes the Windows command prompt.<br/>PUSHD Saves the current directory then changes it.<br/>RD Removes a directory.<br/>RECOVER Recovers readable information from a bad or defective disk.<br/>REM Records comments (remarks) in batch files or CONFIG.SYS.<br/>REN Renames a file or files.<br/>RENAME Renames a file or files.<br/>REPLACE Replaces files.<br/>RMDIR Removes a directory.<br/>ROBOCOPY Advanced utility to copy files and directory trees<br/>SET Displays, sets, or removes Windows environment variables.<br/>SETLOCAL Begins localization of environment changes in a batch file.<br/>SC Displays or configures services (background processes).<br/>SCHTASKS Schedules commands and programs to run on a computer.<br/>SHIFT Shifts the position of replaceable parameters in batch files.<br/>SHUTDOWN Allows proper local or remote shutdown of machine.<br/>SORT Sorts input.<br/>START Starts a separate window to run a specified program or command.<br/>SUBST Associates a path with a drive letter.<br/>SYSTEMINFO Displays machine specific properties and configuration.<br/>TASKLIST Displays all currently running tasks including services.<br/>TASKKILL Kill or stop a running process or application.<br/>TIME Displays or sets the system time.<br/>TITLE Sets the window title for a CMD.EXE session.<br/>TREE Graphically displays the directory structure of a drive or<br/> path.<br/>TYPE Displays the contents of a text file.<br/>VER Displays the Windows version.<br/>VERIFY Tells Windows whether to verify that your files are written<br/> correctly to a disk.<br/>VOL Displays a disk volume label and serial number.<br/>XCOPY Copies files and directory trees.<br/>WMIC Displays WMI information inside interactive command shell.<br/><br/>For more information on tools see the command-line reference in the online help.<br/><br/>C:\\><br/>Victoria, could you explain the reason you posted that cat picture? Have you read the forum rules?<br/> Quote from: Salmon Trout on August 11, 2010, 03:23:57 PM</p><blockquote>Victoria, could you explain the reason you posted that cat picture? Have you read the forum rules?<br/><br/></blockquote> <br/>No, I have not read any rules about Cats. Where do I read about Cats?<br/><br/>•Make posts / comments that only relate to the original question / topic.<br/><br/>I cannot <a href="https://interviewquestions.tuteehub.com/tag/delete-karana-436574" style="font-weight:bold;" target="_blank" title="Click to know more about DELETE">DELETE</a> the Cat Picture. Time ran out.<br/><br/> Quote<blockquote>No, I have not read any rules about Cats. Where do I read about Cats?</blockquote> <br/>How is that Bill has been back more than a week and nothing has been done?<br/><br/>very convincing, Bill.<br/> Quote from: Manasito on August 09, 2010, 05:50:22 PM<blockquote> I haven\'t tried anything yet. But your list has been usefull, as well as the link you posted.<br/></blockquote> <br/>Manasito,<br/><br/>Im sorry the Thread got off topic.<br/><br/>You should now have a better understanding how to list your folders, music files and other files.<br/><br/>Good Luck<br/><br/>Ignore the off topic posts that offer no suggestions of how to list your files.<br/><br/>dir /?<br/><br/></body></html> | |