Articles

Copying folders from one directory to another

July 27, 2009 at 23:56:34
Specs: Windows XP, Dual core/ 2GB

Is there any way to copy a folder from one directory to another if the folder name contains more than 8 characters including space(s)? Suppose I want to copy the folder "New Folder" from "Folder1" to "Folder2". How can I do this?

See More: Copying folders from one directory to another

Report •


#1
July 28, 2009 at 01:36:49

right click on the folder and select copy. Then go to the other folder and right click and select paste.

Toronto Web Hosting


Report •

#2
July 28, 2009 at 19:27:40

(If you must do it in DOS/command prompt. . .)

With folder names (or file names--the syntax is the same) containing a space you ignore the space and use the first 6 letters--or all the letter if there's less than 6--and put a ~1 at the end. So the dos name of your 'new folder' would be newfol~1. With folder names without a space you again use the first 6 letters followed by a ~1. If a folder has no space and has 8 or less letters in its name then you just use the name itself and no ~1 stuff.

But Dave, you say, what happens if when adding the ~1 more than one folder is named the same? In that case subsequent folders have a ~2, ~3, etc. If you get 10 or more then you only use the first 5 letters. So in that case 'new folder' is newfo~10.

Win 9x command prompt will show the dos file names, XP command prompt won't. So if there's confictling folder names in XP you may have to guess until you get the right one.

Then for example if 'new folder' is contained in 'folder1 and both 'folder1 and 'folder2' are in the root directory then:

XCOPY C:\FOLDER1\NEWFOL~1\*.* C:\FOLDER2\NEWFOL~1/e

will copy the files.

Using the xcopy command with the /e switch will copy the contents of 'new folder' including all nested subfolders even those that are empty


Report •

#3
July 29, 2009 at 06:26:52

Forgive me if I'm wrong but I thinks this might be a "the black box in windows is dos right?" question.


If you ever need to get a dos alias for a file name in xp you can either run the file name through a for loop or pass it to a batch file as a parameter(double quoted as nessacery) and use %%~s<variable> or %~s<parameter number>.


If this is the xp command processor(cmd.exe) you don't need to use dos file name alias', in fact it is possible to turn them off completely via fsutil or the registry so the can't be used.

Generally in cmd.exe the only programs that can't handle long file names/spaces are legacy (genuine)dos apps. For anything that has spaces or ampersands, just embrace the whole file/folder name in double quotes(i.e xcopy /i /e "c:\new folder" "c:\files&folders").


Report •

Related Solutions

#4
July 29, 2009 at 15:50:05

I had totally forgotten about the double quotes when using dos commands in XP command prompt. Thanks for the reminder. Except when dealing with excruciatingly long file or folder names it's probably easier using that method, especially if dos format can give mulitple matching file names that command prompt doesn't show.

Report •

#5
July 29, 2009 at 19:35:57

True really long files names can be a pain, at least with a batch you don't have to type it every time. On the xp command line I find it's even easier to type the first few characters then hit tab for autocompletion, it will even double quotes for you as necessary.

@Daisy B.
I just got your PM, let me know what you don't understand and I'll try to explain it if you like.

Just to clear things up is this for genuine DOS, or the command processor inside windows? If in windows what version?


Report •


Ask Question