Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
dir /s /b for directories not subs
Name: masimar Date: May 11, 2006 at 18:05:51 Pacific OS: na CPU/Ram: na Product: na
Comment:
Can Anybody tell be how to do a dir in windows xp and weed out the subdirectories? dir /s /b works great, but I want only one level of directories to zip and replace the folders on the fly. The subs are just a nuiscance. I've never wanted only one level before and can't figure out how to do it. I'll do anything for help, hell, I'll #^@% your &^%$! Well, probably not, but I would appreciate it.
Name: Valerie (by Garibaldi) Date: May 11, 2006 at 19:15:26 Pacific
Reply:
Dir/ad/on/b ??
0
Response Number 2
Name: masimar Date: May 11, 2006 at 19:33:36 Pacific
Reply:
Well, yeah. I really want the entire path that you get with dir /s /b . I can't figure how to exclude the subdirectories. That would be perfect. But I've been parsing all day and my mind wants to give up. Thanks for the reply.
Mark
0
Response Number 3
Name: CyberSlug Date: May 11, 2006 at 22:23:41 Pacific
Reply:
I *think* the following will work. Replace the echos with the commands you want.
@echo off
REM Recursive batch file to list files only up only to one directory deep REM Use flag to limit recursion to one level if "%1" == "stop" goto recursive_case
REM list files in current level FOR /F %%i IN ('dir /b /a-D') DO echo %cd%\%%i
REM list files in subfolders FOR /F %%i IN ('dir /b /aD') DO call %~f0 stop %cd%\%%i
:base_case pause exit
:recursive_case cd %2 FOR /f "tokens=*" %%f IN ('dir /b') DO echo %cd%\%%f
0
Response Number 4
Name: masimar Date: May 12, 2006 at 05:54:29 Pacific
Reply:
Yeah, that does the trick: FOR /F %%i IN ('dir /b /aD') DO call %~f0 stop %cd%\%%i>>directory.txt will write just the directories in the root. Thanks a lot, that's a big help.
Summary: Im new to this whole batch file thing but basically this is what im trying to accomplish. We have two servers that mirror each other - a development box which is X: and the actual live site, which is ...
Summary: @echo off > %TEMP%\DLIST setLocal EnableDelayedExpansion set #=0 for /f "tokens=*" %%D in ('dir/s/b/ad \temp\-') do ( set /a #+=1 echo [!#!] %%D >> %TEMP%\DLIST ) type %TEMP%\DLIST set /p dirNUM=choos...
Summary: Actually it does not work. This command... set T=%%~Ta does not set T to any thing and if you echo it it just says echo is off. Here is the code I am using to test with... @echo off & setLocal EnableD...