copy
Moderator: DosItHelp
Re: copy
viewtopic.php?f=3&t=6108
Maybe you could do this:
or
Saso
Maybe you could do this:
Code: Select all
help copy
Code: Select all
copy /?
Re: copy
@echo off
setlocal enabledelayedexpansion
xcopy /D /U /Y "anyfolder\batch name as folder name\anyfolder\*" "anyfolder\spi-batch name as folder name\anyfolder\"
xcopy /E "anyfolder\batch name as folder name\anyfolder\" "anyfolder\spi-batch name as folder name\anyfolder\"
xcopy /D /U /Y "anyfolder\batch name as folder name\anyfolder\*" "anyfolder\spi-batch name as folder name\anyfolder\"
echo Finished
pause
in need specific multiple extensions and batch file name as the folder name in both source and destination.
setlocal enabledelayedexpansion
xcopy /D /U /Y "anyfolder\batch name as folder name\anyfolder\*" "anyfolder\spi-batch name as folder name\anyfolder\"
xcopy /E "anyfolder\batch name as folder name\anyfolder\" "anyfolder\spi-batch name as folder name\anyfolder\"
xcopy /D /U /Y "anyfolder\batch name as folder name\anyfolder\*" "anyfolder\spi-batch name as folder name\anyfolder\"
echo Finished
pause
in need specific multiple extensions and batch file name as the folder name in both source and destination.
Re: copy
need to copy specific files extension and copy subfolder with specific files extension
Code: Select all
@echo off
setlocal enabledelayedexpansion
for %%A in (*.bat) do (
for /f "delims=" %%B in ("%%A") do set fname=%%~nB
for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
echo folder name [b]!folname![/b]
echo
xcopy /Y "E:\folder1\folder2\[b]!folname![/b]\folder3\" "G:\folder1\folder2\[b]spi-!folname![/b]\folder3" [b](e.g., *.jpg; *.tiff; *.eps)[/b]
xcopy /E /Y "E:\folder1\folder2\[b]!folname![/b]\folder3\" "G:\folder1\folder2\spi-!folname!\folder3" [b](e.g., subfolder)[/b]
xcopy /Y "E:\folder1\folder2\[b]!folname![/b]\folder3\" "G:\folder1\folder2\[b]spi-!folname![/b]\" [b](e.g., *.jpg; *.tiff; *.eps)[/b]
)
echo Finished
pause
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: copy
%0 returns the entirety of what was typed when the script was called. Presumably they're looking for %~n0.miskox wrote: ↑05 Dec 2022 04:53%0 returns batch name.
SasoCode: Select all
@echo %0
P.S. Use code tags, please.
Re: copy
What happens if you execute your .bat file? (of course remove BOLD tags)
Note I added a dot after the ECHO command.
your notes were not REMed so that would cause problems. Also I added two back slashes in the first two XCOPY commands.
Do you see the correct command syntax If you run this code? Can you run it in a test enironemnt?
Saso
Code: Select all
@echo off
setlocal enabledelayedexpansion
for %%A in (*.bat) do (
for /f "delims=" %%B in ("%%A") do set fname=%%~nB
for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
echo folder name !folname!
echo.
ECHO xcopy /Y "E:\folder1\folder2\!folname!\folder3\" "G:\folder1\folder2\spi-!folname!\folder3\"
ECHO xcopy /E /Y "E:\folder1\folder2\!folname!\folder3\" "G:\folder1\folder2\spi-!folname!\folder3\"
ECHO xcopy /Y "E:\folder1\folder2\!folname!\folder3\" "G:\folder1\folder2\spi-!folname!\"
)
echo Finished
pause
your notes were not REMed so that would cause problems. Also I added two back slashes in the first two XCOPY commands.
Do you see the correct command syntax If you run this code? Can you run it in a test enironemnt?
Saso
Re: copy
Let me give you this link again: viewtopic.php?f=3&t=6108
We are all wasting our time because your original post does not (and additional posts) provide enough information. You would probably already have a solution if your original post had all the information required:
You wanted to know
"1. batch file name as folder name"
and I gave you the answer to use %0. And then it turns out that you want to process the list of all the *.bat files in the [current] directory. And for that you need something else.
Saso
We are all wasting our time because your original post does not (and additional posts) provide enough information. You would probably already have a solution if your original post had all the information required:
You wanted to know
"1. batch file name as folder name"
and I gave you the answer to use %0. And then it turns out that you want to process the list of all the *.bat files in the [current] directory. And for that you need something else.
Maybe you could provide extensions in a list - never tried that (I don't use XCOPY) - so you could duplicate XCOPY commands for this. In short something like this:need copy with extension (e.g., *.jpg; *.tiff; *.eps) how to include this
Code: Select all
REM modify your XCOPY command of course
XCOPY *.jpg outfolder\
XCOPY *.tiff outfolder\
XCOPY *.eps outfolder\