1.

Solve : Replacing long filenames with wildcards in Windows 7?

Answer»

Hi all, I'm trying to create a batch code to copy some information from one drive to another every time my PC starts up and I'm having trouble with the syntax.

The command I'm USING is

copy "\\server1\directory1\file*.*" "\\server2\Directory2 Long Filename\Directory3 Long Filename\*.*"---

I've tried various versions of this, including changing "Long Filename" to "longfi~1", using xcopy, changing capitalisation etc but all to no avail.

The error message I'm getting seems to be referring to the destination location, and says "The network name cannot be found".

Any help to automate this would be much appreciated, thanks.Try removing the "---" at the end of the target path.Sorry, that was my formatting error, I'd posted it elsewhere and was using that just to show it wasn't part of the main text. The "---" isn't in the command I'm trying to use.Just in case anybody is refraining from answering as they think this might be some sort of homework, I'd just like to state for the record that I'm thirty years old and trying to automate a backup task every morning when my PC switches on. I've used generic names as I don't think it would be good business practise to give out the names of my company's servers and file structure. :-)Aww c'mon...
Give us the FULL rundown... The copy command should work. Maybe you do not have access permissions on the server.I can copy it manually using the Windows interface, but not using DOS commands.

What's the correct way of dealing with long filenames, should I truncate them using a tilde, replace spaces with underscores, put everything in quotes or something else entirely?Are you running the copy command in an Administrator command prompt?Quote

The error message I'm getting seems to be referring to the destination location, and says "The network name cannot be found".

When using the universal naming convention (UNC) the format is \\server-name\shared-resource-pathname. Either Server2 is not correct, or 'Directory2 Long Filename' is not a shared resource. Note: you can also use ADMINISTRATIVE shares (format: drive$) in place of the shared-resource-pathname, but you must get the server name correct. Check to see if you're connected to the server and what resources are shared.

You notation with the quotes is correct, so you shouldn't need to use short names.

Hope this helps somewhat. Thanks for the CLARIFICATION, I went back and had a look at from a DIFFERENT angle and I'd been a muppet and missed out part of the destination path.

Thanks all for your help!


Discussion

No Comment Found