command prompt commands (MOVE) - cmd

i am using windows 7 32 bit ultimate, i want to know if anyone can use cmd or command prompt (move command) and fix this problem :
i have folder (mypro) on drive (C) and i also have same folder on (D) drive. now when i use cmd like the following it says "access denied"
c:> move mypro d:\
access denied
c:>
c:> move/y mypro d:\
access denied
c:>
c:> move/-y mypro d:\
access denied
c:>
also i i run with administration rights but its not working again

In case there are no subfolders in your c:\mypro\ -folder, try this:
move /y mypro\* d:\mypro\
In case you've got subfolders the solution seems to require a BAT-file.
If you need that, let me know.

I prefer using Xcopy and then remove the directory on C,
I think you have a directory "Mypro" on C partition, and you have the same folder "Mypro" on partition D:
You can try this solution:
First: copy entire directory within sub-directory using Xcopy like this
C:>xcopy /s /e /y MyPro d:\MyPro
/s: Copies directories and subdirectories except for empty ones.
/e: Copies directories and subdirectories, including empty ones.
/y: Suppresses prompting to confirm you want to overwrite an
existing destination file.
Second: remove the entire directory "MyPro" on partition C while you move all files/folders
C:>rmdir /s mypro
/s: Removes all directories and files in the specified directory
in addition to the directory itself.
Please let me know if your problem doesn't solve.
C:\>xcopy /s /e /y MyPro d:\MyPro
C:\>rmdir /s mypro

Related

Copy folder to current path open in Command Prompt

I'm trying to create a batch file that copies one folder to the current path open in command prompt.
This is the code I have, but it doesn't work.
#echo off
xcopy /s c:\Users\Alexander\Documents\Other d:\%cd%
pause
Over complicating things...
Just use ".", which means current directory, i.e.:
xcopy /s c:\blah\blah .

Windows xcopy 0 File(s) copied

I am trying to copy a directory but get the following:
xcopy ..\node_modules\ \node_modules\
0 File(s) copied
I run as administrator, but still get the error. Any ideas please?
p.s I actually use the following to stipulate it's a directory. But the above also fails:
echo d | xcopy /d /y ..\node_modules\ \node_modules\
Thanks
You can use the xcopy /E flag to copy the entire directory and subdirectories. Also remove the starting \ of the destination. The trailing slash should prevent the file or directory prompt.
xcopy /E ..\node_modules node_modules\
xcopy ..\node_modules\* \node_modules\
You are specifying the source directory, but not which files to copy.
To copy all the contents like folder, sub-folder or chain of folders we can use below command:
xcopy file-to-copy-path\ where-to-copy-path\ /s /i
/s copies folders and sub-folders
/i If in doubt always assume the destination is a folder e.g. when the destination does not exist.

Windows cmd shell xcopy to network directory doesn't work

Im trying to make a batch file that will copy all new files and folders from a source folder to an network directory. All the new subdirectories and new files should be copied (backup).
My code:
xcopy "C:\Source" "T:\Backup" /d/i/s/q
(/d for only new files, /i because source is a dir, /s for all the subdirs and files, /q just to supress the copy text)
Source contains both subdirectories and files (.txt).
The first run it copies Everything as it should. When I add a new .txt file to one of the existing subdirectories and run it again I get the message:
"An error occured when the file The directory is not empty. was being created.
The folder "T:\Backup" could not be created.
0 files copied.
(Translated from Swedish so not 100% original)
The thing is when I try this command to a local source like e.g. "C:\test" and do the same procedure it works.
Anyone who can understand why this doesn't work for the network drive?
Should I try Another command such as robocopy?
Skip xcopy and use robocopy with the /E flag instead. It's built into all recent versions of Windows. Free download for XP.
Example:
robocopy c:\source T:\backup /E
That will copy all the files in the "source" folder to the "backup" folder that haven't been copied already.
And if you don't want to have the output shown on the console (equivalent to the /Q option in xcopy):
robocopy c:\source T:\backup /E /LOG:nul
Robocopy must be better because it should create directories with the \E switch. No overwrites for files, just adds a file with extra letters or extension <> command. Still must defrag.
XCOPY "DRIVE LETTER:\windows.old\USERS" "\computername\D\NAME\" /D /E /C /R /I /K /Y /f

Delete Files with Windows Command Prompt

There is a shared folder in my D drive as works (D:\works). I need to delete all the files in that folder and sub folders except word and excel files in there. how can i do this ?
You could do something similar to what this guy's done: http://www.codesingh.com/2009/08/using-robocopy-to-delete-old-files-from.html
Something like this should work:
mkdir D:\_tempDelete
robocopy D:\works D:\_tempDelete /e /MOVE /XF *.xls* *.doc*
rmdir D:\_tempDelete /s /q
Provided you have permissions to create and delete folders on D:. Otherwise you could just move the files somewhere on your local drive and delete them from there.

Windows batch command to move all folders in a directory with exceptions

I am trying to write a Windows Batch file that will allow me to move all directories within a given source directory into a target directory that exists within that source directory.
Obviously my move command with need to only apply to directories and also exclude the target directory from being processed.
Is this possible with a Windows batch command?
Robocopy (present in recent versions of windows or downloadable from the WRK) can do this, just use the /xd switch to exclude the target directory from the copy;
robocopy c:\source\ c:\source\target\ *.* /E /XD c:\source\target\ /move
FOR /d %%i IN (*) DO IF NOT "%%i"=="target" move "%%i" target
That won't work - you'll get an error telling you the target directory is inside the source directory or so, even if you explicitly exclude the target directory. What you can do is move the directories to a temporary location which is not under the source, and then move them into the target.
BTW, using the move command won't let you specify folders to exclude. For that you can use xcopy, but note that it will copy the folders, as opposed to move them. If that matters, you can delete whatever you want afterwards, just make sure you don't delete the target dir, which is in the source dir...
Using robocopy included with Windows 7, I found the /XD option did not prevent the source folder from also being moved.
Solution:
SET MoveDirSource=\\Server\Folder
SET MoveDirDestination=Z:\Folder
FOR /D %%i IN ("%MoveDirSource%\*") DO ROBOCOPY /MOVE /E "%%i" "%MoveDirDestination%\%%~nxi"
This loops through the top level folders and runs robocopy for each.
NB: Robocopy mentioned above using the /move flag will copy the files and then delete them from the source folder rather than moving the files. This may be critical if moving large numbers of files from one location to another on the same disk (because move is virtually instantaneous, while copying is a much slower operation)
On windows batch:
FOR /d %%i IN (MySourceDirectory\*) DO move "%%i" MyTargetDirectory\%%~ni
The above command moves all directories found in MySourceDirectory (/d) to MyTargetDirectory using the original directory name
(~ni) Robocopy's move first does a copy, then delete, so it is slower.
This works for me:
move c:\fromDir\*.* c:\toDir\

Resources