Gå til innhold

Kopiere en hel mappe med batch


Anbefalte innlegg

Hei! Jeg lurer på hvordan jeg kan kopiere en hel mappe med alle filer og mapper innenfor. Noen som vet det?

Her er scriptet jeg bruker som ikke fungerer:

 

echo off
cls
echo Push a button to copy SAM, SYSTEM and the Documents and Settings folder.
pause>nul
md ..\sam_system
xcopy %systemroot%\repair\sam ..\sam_system
xcopy %systemroot%\repair\system ..\sam_system



if exist c:\Docume~1 goto c_copy
else
echo There is no Documents and Settings folder in the C drive.

if exist a:\Docume~1 goto a_copy
else
echo There is no Documents and Settings folder in the A drive.

if exist d:\Docume~1 goto d_copy
else
echo There is no Documents and Settings folder in the D drive.

if exist e:\Docume~1 goto e_copy
else
echo There is no Documents and Settings folder in the E drive.

if exist f:\Docume~1 goto f_copy
else
echo There is no Documents and Settings folder in the F drive.

:c_copy
md ..\c_drive
xcopy c:\Docume~1 ..\c_drive
echo The Documents and Settings folder in the C drive has been copied.

:a_copy
md ..\a_drive
xcopy c:\Docume~1 ..\a_drive
echo The Documents and Settings folder in the A drive has been copied.

:d_copy
md ..\d_drive
xcopy c:\Docume~1 ..\d_drive
echo The Documents and Settings folder in the D drive has been copied.

:e_copy
md ..\e_drive
xcopy c:\Docume~1 ..\e_drive
echo The Documents and Settings folder in the E drive has been copied.

:f_copy
md ..\f_drive
xcopy c:\Docume~1 ..\f_drive
echo The Documents and Settings folder in the F drive has been copied.

pause>nul

 

Takk for svar :)

Lenke til kommentar
Videoannonse
Annonse

Problemet ligger i at du bruker forkortede navn (c:\Docume~1). Istedet burde du bruke hele banen og putter gåseøyner rundt slikt:

 

XCOPY "C:\Documents and Settings\Username\This is a file with long filename.TXT" "C:\Some folder with long name\Folder\"

 

Og jeg er usikker på bruke av ..\ istedet for å angi fullstendig bane.

Ellers vil jeg anbefale deg å se på parametrene til XCOPY ved å skrive XCOPY /? i CMD. Jeg vil anbefale deg å ta med parametrene /E /F /H /K så du får med filattributter, tomme mapper (for å bevare fullstendig mappestruktur) og skjulte filer. Eksempel:

 

XCOPY "C:\Documents and Settings\Username\This is a file with long filename.TXT" "C:\Some folder with long name\Folder\" /E /F /H /K

Endret av skag1
Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...