![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Help understanding one liner folks I'm trying to understand the following one liner (in order to eventually amend it) for /f "tokens=*" %%a in ('dir /s /b *.pdf 2^>NUL') do echo %%a I understand what it does (list all pdf files in a file structure) but not how. Not even sure it's vbscript (sorry . Tried to google itwithout much success (probably because "for" is a pretty common term...). Anyway some pointer / help would be much appreciated Regards alex |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Help understanding one liner AlexT. wrote: Quote: > > I'm trying to understand the following one liner (in order to > eventually amend it) > > for /f "tokens=*" %%a in ('dir /s /b *.pdf 2^>NUL') do echo %%a > > I understand what it does (list all pdf files in a file structure) but > not how. Not even sure it's vbscript (sorry . Tried to google it> without much success (probably because "for" is a pretty common > term...). Open the Command Prompt and type "for /?" for documentation or read <http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx> -- Steve Those who know how to win are much more numerous than those who know how to make proper use of their victories. -Polybius |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Help understanding one liner "AlexT." <google@xxxxxx> wrote in message news:97bc4c3a-357f-430c-8276-305aab78c522@xxxxxx Quote: > folks > > I'm trying to understand the following one liner (in order to > eventually amend it) > > for /f "tokens=*" %%a in ('dir /s /b *.pdf 2^>NUL') do echo %%a > > I understand what it does (list all pdf files in a file structure) but > not how. Not even sure it's vbscript (sorry . Tried to google it> without much success (probably because "for" is a pretty common > term...). > > Anyway some pointer / help would be much appreciated how it works is going to take more than a pointer to read FOR/? help. Actually, this is three commands on one line. FOR, DIR and ECHO but lets look at the DIR command first. dir /s /b *.pdf This returns a bare directory output of all .pdf files in current and all subdirectories. The /b tells DIR to return a bare listing (filenames only) and the /s tells it to recurs subdirectories (this returns the full file paths). The 2^>NUL hides any error messages. Actually, 2>NUL hides error messages but since the command is nested within the FOR command, the output symbol > needs to be escaped with a ^ caret. Because the FOR command used the /f switch, this allows the FOR command to execute the DIR command because it is enclosed within single quotes. The output of DIR is fed to the FOR command for processing. The "tokens=*" tells the FOR command to pass each line of output irrespective of any spaces or other delimiter characters. The ECHO command tells it to send the output to screen. For further information, read the help from these commands. FOR/? DIR/? ECHO/? -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Help understanding one liner On Aug 28, 6:48*am, "Todd Vargo" <tlva...@xxxxxx> wrote: Quote: > "AlexT." <goo...@xxxxxx> wrote in message > > news:97bc4c3a-357f-430c-8276-305aab78c522@xxxxxx > Quote: > > folks Quote: > > I'm trying to understand the followingoneliner(in order to > > eventually amend it) Quote: > > for /f "tokens=*" %%a in ('dir /s /b *.pdf 2^>NUL') do echo %%a Quote: > > I understand what it does (list all pdf files in a file structure) but > > not how. Not even sure it's vbscript (sorry . Tried to google it> > without much success (probably because "for" is a pretty common > > term...). Quote: > > Anyway some pointer / help would be much appreciated > Alex, as others mentioned, this is batch code not vbscript. To understand > how it works is going to take more than a pointer to read FOR/? help. > Actually, this is three commands ononeline. FOR, DIR and ECHO but lets > look at the DIR command first. > > * * dir /s /b *.pdf > > This returns a bare directory output of all .pdf files in current and all > subdirectories. The /b tells DIR to return a bare listing (filenames only) > and the /s tells it to recurs subdirectories (this returns the full file > paths). The 2^>NUL hides any error messages. Actually, 2>NUL hides error > messages but since the command is nested within the FOR command, the output > symbol > needs to be escaped with a ^ caret. Because the FOR command used > the /f switch, this allows the FOR command to execute the DIR command > because it is enclosed within single quotes. The output of DIR is fed to the > FOR command for processing. The "tokens=*" tells the FOR command to pass > each line of output irrespective of any spaces or other delimiter > characters. The ECHO command tells it to send the output to screen. > > For further information, read the help from these commands. > > FOR/? > DIR/? > ECHO/? > > -- > Todd Vargo > (Post questions to group only. Remove "z" to email personal messages) understand this one and to amend it to my liking ![]() |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| one-liner PowerShell | PowerShell | |||
| Exchange Powershell one-liner to Mail-Enable Contacts | PowerShell | |||
| Help Understanding INNER JOIN | VB Script | |||
| Multi-line text becomes a one-liner | PowerShell | |||
| Exchange 2007 "Activate the PowerShell" One liner Contest | PowerShell | |||