Copy multiple files to different directorys
Moderator: DosItHelp
Copy multiple files to different directorys
Hi,
I have got a directory, where i place users id files.
These id files have to go to the users own folder on server.
the source is c:/id
files that can be in this folder :
joe.id
jane.id
blabla.id
These files need to be copied to
\\server\NotesProfiles\username\
So for joe.id
\\server\NotesProfiles\joe\joe.id
the id file names can change.
Does somebody has a solution to do this using a batchfile, where i just click the file, without any user input from that point.
I have got a directory, where i place users id files.
These id files have to go to the users own folder on server.
the source is c:/id
files that can be in this folder :
joe.id
jane.id
blabla.id
These files need to be copied to
\\server\NotesProfiles\username\
So for joe.id
\\server\NotesProfiles\joe\joe.id
the id file names can change.
Does somebody has a solution to do this using a batchfile, where i just click the file, without any user input from that point.
-
- Expert
- Posts: 80
- Joined: 04 Feb 2009 10:03
This should get you going down a path that would help... with some tweaking.
-Rick
-Rick
Code: Select all
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
For /F "Delims=" %%F In ('Dir /B *.id') Do (
Set "f=%%~nF"
If NOT Exist \\Server\NotesProfiles\!f! (
MD \\Server\NotesProfiles\!f!
)
Copy /v %%F \\Server\NotesProfiles
)
Hi,
I got it working now.
but still one issue.
If I copy the id files to the folders on the server (these folders allready exist).
If the folders on the server do not exist, the id file can't be copied and I need an overview of the id files that haven't been copied.
So as an example
c:\test\test
c:\test\bla
these folders exist, so test.id and bla.id can be copied.
the folder qwerty doesn't exist so qwerty.id can't be copied and it has to say qwerty.id isn't copied.
This is because the folders are created when checking in the users, the id files are created seperatly. when an id file has no corresponding folder, the name of id file is wrong and has to be done again. and no new folder can be created, this because of login issues.
thanks for the heads up on the code.
I got it working now.
but still one issue.
If I copy the id files to the folders on the server (these folders allready exist).
If the folders on the server do not exist, the id file can't be copied and I need an overview of the id files that haven't been copied.
Code: Select all
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
For /F "Delims=" %%F In ('Dir /B *.id') Do (
Set "f=%%~nF"
If Exist c:\test\!f! (
Copy /v %%F c:\test\!f!
If NOT Exist c:\test\!f! (
echo This name doesn't exist
))
)
pause
So as an example
c:\test\test
c:\test\bla
these folders exist, so test.id and bla.id can be copied.
the folder qwerty doesn't exist so qwerty.id can't be copied and it has to say qwerty.id isn't copied.
This is because the folders are created when checking in the users, the id files are created seperatly. when an id file has no corresponding folder, the name of id file is wrong and has to be done again. and no new folder can be created, this because of login issues.
thanks for the heads up on the code.
-
- Expert
- Posts: 80
- Joined: 04 Feb 2009 10:03
Inside your loop, just add a test for the Folder. This assumes you're looking for folder names that match the File Name of the ID files in the "C:\Test" folder.
Code: Select all
For /F "Delims=" %%F In ('Dir /B C:\ID\*.id') Do (
Set "f=%%~nF"
If Exist c:\test\!f! (
Copy /v %%F c:\test\!f!
) Else (
echo The Folder !f! Does not Exist
)
)
Hi,
Thanks, this works.
But it is not easy to overview this when it is used to copy for example 100 files.
I get the following in my cmd window :
For each id file I see the complete coding.
Set "f=bla"
If Exist c:\test\bla (Copy /v bla.txt c:\test\!f! ) Else (echo The Folder bla
Does not Exist )
)
1 file(s) copied.
Set "f=blaf"
If Exist c:\test\bla (Copy /v bla.txt c:\test\!f! ) Else (echo The Folder bla
Does not Exist )
)
The Folder blaf Does not Exist
and this for every file.
Is there a way I can not see this and only see The folders that do not exist, like the underlined
Thanks, this works.
But it is not easy to overview this when it is used to copy for example 100 files.
I get the following in my cmd window :
For each id file I see the complete coding.
Set "f=bla"
If Exist c:\test\bla (Copy /v bla.txt c:\test\!f! ) Else (echo The Folder bla
Does not Exist )
)
1 file(s) copied.
Set "f=blaf"
If Exist c:\test\bla (Copy /v bla.txt c:\test\!f! ) Else (echo The Folder bla
Does not Exist )
)
The Folder blaf Does not Exist
and this for every file.
Is there a way I can not see this and only see The folders that do not exist, like the underlined
-
- Expert
- Posts: 80
- Joined: 04 Feb 2009 10:03
-
- Expert
- Posts: 80
- Joined: 04 Feb 2009 10:03