Create a directory in multiple different directories

  • Thread starter Thread starter Charles Theodore
  • Start date Start date
C

Charles Theodore

Hi everyone,

Running Windows XP pro and looking for a way to make my batch optimized.

--------------------------actual code----------------------------------
@echo off
set pathx=\\filesrv1\MSI\Graphic
for /d %%a in (%pathx%\*.*) do md "%%a\INPUT"
set pathx=\\filesrv1\MSI\Oracle
for /d %%a in (%pathx%\*.*) do md "%%a\INPUT"
set pathx=\\filesrv1\MSI\Tools
for /d %%a in (%pathx%\*.*) do md "%%a\INPUT"
set pathx=

--------------------------desired code----------------------------------
A program that can parse all directories to create an INPUT directory.
Don't want to set every time a static pathx variable for each different directories.

Example:

\\filesrv1\MSI\Graphic\Photoshop\INPUT
\\filesrv1\MSI\Oracle\Client\INPUT
\\filesrv1\MSI\Tools\AdAware\INPUT
.... and so on on many directories.

Thank you very much!

Charles
 
Charles said:
Hi everyone,

Running Windows XP pro and looking for a way to make my batch optimized.

--------------------------actual code----------------------------------
@echo off
set pathx=\\filesrv1\MSI\Graphic
<snip>

This doesn't sound like a repititous task, so why not create a dir
listing with folders only and edit it?

Your description remains unclear, do you want only the "leaves" in your
tree to contain that "input" folder ?

This is not tested.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
set pathx=\\filesrv1\MSI
for /f "delims=" %%A in ('dir /B/S/AD %pathx%') do call :sub "%%A"
goto :eof
:sub
:: check if this is an INPUT folder
if /I "%~nx1" EQU "INPUT" goto :eof
:: check if already present
if exist "%~1\INPUT" goto :eof
:: check for leaves
for /F "delims=" %%B in ('dir /B/S/AD %1') do goto :eof
md "%~1\INPUT"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HTH
 
Matthias Tacke said:
<snip>

This doesn't sound like a repititous task, so why not create a dir
listing with folders only and edit it?

Your description remains unclear, do you want only the "leaves" in your
tree to contain that "input" folder ?

This is not tested.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
set pathx=\\filesrv1\MSI
for /f "delims=" %%A in ('dir /B/S/AD %pathx%') do call :sub "%%A"
goto :eof
:sub
:: check if this is an INPUT folder
if /I "%~nx1" EQU "INPUT" goto :eof
:: check if already present
if exist "%~1\INPUT" goto :eof
:: check for leaves
for /F "delims=" %%B in ('dir /B/S/AD %1') do goto :eof
md "%~1\INPUT"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HTH

To your question1: How do you see that? I'm not sure to exactly
understand
your proposition :-(

To your question2: Yes, that's correct!

When i run your script, it works great to create the INPUT directory
when the directory is already empty or contain a filename (for
example, the Photoshop dir.). When the dir have already a
sub-directory, it doesn't work.

Let me show exactly the problem with an example:
\\filesrv1\MSI\Graphic\Photoshop\(if that dir is empty, creation of
INPUT work)
\\filesrv1\MSI\Graphic\Photoshop\(if that dir have a filename,
creation of INPUT work)
\\filesrv1\MSI\Graphic\Photoshop\(if that dir have a sub-directory,
it doesn't work to create the INPUT directory)

Thank you, for help !!!

Charles
 
Matthias Tacke said:
<snip>

This doesn't sound like a repititous task, so why not create a dir
listing with folders only and edit it?

Your description remains unclear, do you want only the "leaves" in your
tree to contain that "input" folder ?

This is not tested.
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
@echo off
setlocal
set pathx=\\filesrv1\MSI
for /f "delims=" %%A in ('dir /B/S/AD %pathx%') do call :sub "%%A"
goto :eof
:sub
:: check if this is an INPUT folder
if /I "%~nx1" EQU "INPUT" goto :eof
:: check if already present
if exist "%~1\INPUT" goto :eof
:: check for leaves
for /F "delims=" %%B in ('dir /B/S/AD %1') do goto :eof
md "%~1\INPUT"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

HTH

A mistake...

Please, ignore my previous reply, the script were "word wrapped" with
notepad... I will using textpad for my future needs!

Mattias, just one tricky thing i'm wondering how to resolve is how to
make the script to create the INPUT directory just beside Photoshop,
Client and AdAware directories, not in next sub-direcories, when
available.

Example:
\\filesrv1\MSI\Graphic\Photoshop (INPUT at the same level of Photoshop
and avoid to create in sub-dir.)
\\filesrv1\MSI\Oracle\Client (INPUT at the same level of Client and
avoid to create in sub-dir.)
\\filesrv1\MSI\Tools\AdAware (INPUT at the same level of AdAware and
avoid to create in sub-dir.)

----------------------------------- your script i have run ----------
@echo off
setlocal
set pathx=D:\filesrv1\msi
for /f "delims=" %%A in ('dir /B/S/AD %pathx%') do call :sub "%%A"
goto :eof
:sub
md "%~1\INPUT"

Thank you and sorry again for confusion on previous post...

Charles
 
A mistake...
Please, ignore my previous reply, the script were "word wrapped" with
notepad... I will using textpad for my future needs!

Mattias, just one tricky thing i'm wondering how to resolve is how to
make the script to create the INPUT directory just beside Photoshop,
Client and AdAware directories, not in next sub-direcories, when
available.

Example:
\\filesrv1\MSI\Graphic\Photoshop (INPUT at the same level of Photoshop
and avoid to create in sub-dir.)
\\filesrv1\MSI\Oracle\Client (INPUT at the same level of Client and
avoid to create in sub-dir.)
\\filesrv1\MSI\Tools\AdAware (INPUT at the same level of AdAware and
avoid to create in sub-dir.)

----------------------------------- your script i have run ----------
@echo off
setlocal
set pathx=D:\filesrv1\msi
for /f "delims=" %%A in ('dir /B/S/AD %pathx%') do call :sub "%%A"
goto :eof
:sub
md "%~1\INPUT"

Thank you and sorry again for confusion on previous post...

Charles


Hi have found a way to create the 'INPUT' directly exactly at the
desired place in directories. Need help to validate my script. The
principle is to locate a file with the extension .zap and when the
filename.zap is localized, make the 'INPUT' directory in that dir.
Basically, at the 4th level of dirs as illustrated below.

\\filesrv1\MSI\Graphic\Photoshop (a .zap file is here and 'INPUT must
be mkdir)
\\filesrv1\MSI\Oracle\Client (a .zap file is here and 'INPUT must be
mkdir)
\\filesrv1\MSI\Tools\AdAware (a .zap file is here and 'INPUT must be
mkdir)

Script who didn't work:
-----------------------
@echo off
setlocal
set pathx=\\\filesrv1\MSI
for /f "delims=" %%A in ('dir/B/S %pathx%\*.zap') do call :sub "%%A"
:sub
for /f "tokens=1-4 delims=\" %%B in (%~1) do (
set %%C=%~1:%%B
)
echo md "%~1\input"

Thank in advance...
 
Charles Theodore wrote:
<snip>

@echo off
setlocal
set pathx=\\filesrv1\MSI
for /f "delims=" %%A in ('dir/B/S/A-D "%pathx%\*.zap"'
) do if not exist "%%~dpAINPUT" md "%%~dpAINPUT"

HTH
 
Matthias Tacke said:
Charles Theodore wrote:
<snip>

@echo off
setlocal
set pathx=\\filesrv1\MSI
for /f "delims=" %%A in ('dir/B/S/A-D "%pathx%\*.zap"'
) do if not exist "%%~dpAINPUT" md "%%~dpAINPUT"

HTH

100% :-)
Thank you so much.

Charles.
 
Back
Top