Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I am trying to make a backup of the files in a corrupted MySQL database before doing a clean install from a different backup file. I am on a windows 7 machine. Someone suggested the following, but the mv command does not work on windows:
mv /var/lib/mysql /var/lib/mysql.old
So instead, I am trying to use robocopy, but I am getting a range of different error messages with each attempt. Here is a screen shot of some of the error messages for my various attempts:
Here is a link to the complete suggested code in a related posting, if it helps anyone suggest the correct syntax: Click Here
I tried xcopy but am getting the following error result:
Then I tried move but got the following results, despite trying a few different ways of doing the slashes:
I added a C:\ProgramData\MySQL\bkup folder to my hard drive and tried the following:
why don't use this syntax ? :
xcopy /s SOURCEDIR DESTDIR
eg: xcopy /s C:\Users\Iman\Desktop\k C:\Users\Iman\Desktop\kk
Here's a possible approach, since the paths seem to be crossing you up:
MD C:\BackupDir
Subst G: c:\BackupDir
Cd C:\MypathtoMysql
G: (Switch to G drive)
Xcopy C:*.* /s /e
That way you're in the directory you want to copy so no need to specify it, and you're copying to a local location rather than a path location.
So, I've done this to prove what I tried to convey in the comments:
Created a directory called C:\ProgramData\directory 1\sub-directory a, and two files in it:
C:\>dir "C:\ProgramData\directory 1\sub-directory a"
Volume in drive C has no label.
Volume Serial Number is 303C-DB3D
Directory of C:\ProgramData\directory 1\sub-directory a
24/05/2014 22:35 <DIR> .
24/05/2014 22:35 <DIR> ..
24/05/2014 22:35 13 file 1
24/05/2014 22:35 13 file 2
2 File(s) 26 bytes
2 Dir(s) 1,076,169,957,376 bytes free
Created a directory C:\ProgramData\directory 2:
C:\>dir "C:\ProgramData\directory 2"
Volume in drive C has no label.
Volume Serial Number is 303C-DB3D
Directory of C:\ProgramData\directory 2
24/05/2014 22:35 <DIR> .
24/05/2014 22:35 <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 1,076,169,957,376 bytes free
Used move to move sub-directory a to C:\ProgramData\directory 2 like so:
C:\>move "C:\ProgramData\directory 1\sub-directory a" "C:\ProgramData\directory 2\sub-directory a"
1 dir(s) moved.
Confirmed that the directory and its files are where they should:
C:\>dir "C:\ProgramData\directory 2\sub-directory a"
Volume in drive C has no label.
Volume Serial Number is 303C-DB3D
Directory of C:\ProgramData\directory 2\sub-directory a
24/05/2014 22:35 <DIR> .
24/05/2014 22:35 <DIR> ..
24/05/2014 22:35 13 file 1
24/05/2014 22:35 13 file 2
2 File(s) 26 bytes
2 Dir(s) 1,076,169,957,376 bytes free
In conclusion:
move can be said to be a renaming operation: The first argument, the source, is the path of the file right now, the second argument, the destination, is what you want it to be.
The parent directory of the destination should exist. E.g. if I move to C:\ProgramData\directory 2\sub-directory a there should already be a directory C:\ProgramData\directory 2.
Arguments that contain a space need to be quoted, like the directory arguments to move. Each argument should be quoted on its own.
Use relative paths when you're sure about what they should be, otherwise use absolute paths.
Is there a reason why you want this done via command line? Why not use a file-diff tool such as Beyond Compare? This tool gives you a visual overview of file differences, but can be used to copy files to another folder for backup as well. Full binary comparison of files in different folders is possible too. See a screenshot. There is a command line version included.
Perhaps this topic from SuperUser can help: https://superuser.com/questions/748069/how-do-i-compare-two-folders-recursively-and-generate-a-list-of-files-and-folder - look down the list of answers and there will be an entry on RoboCopy and its use for a somewhat similar purpose.
Related
This is unrelated to Java, however the error occurs when I try to compile my code.
The semicolon in the command is causing Windows cmd to fail
Example
c:\>cd c:\windows <- no error
c:\>cd c:\windows; <- the semicolon is not being used a command separator but as part of the path
The system cannot find the path specified.
cmd doesn't use semicolon as a command separator. If you want to have two commands on the same line, you need to use & or | (depending on what you're trying to do).
; is used as an argument separator on Windows, but it's not supported by most applications. It has nothing to do with cmd, and cmd isn't supposed to deal with it (applications parse their command lines, not cmd). It also doesn't apply to cmd intrinsics like cd (cd is not an application).
If you have a directory with a semicolon in the name try wrapping it in "double quotes."
Can't exactly verify your problem, but see below.
Z:\[]>dir
Volume in drive Z has no label.
Volume Serial Number is CAC7-078B
Directory of Z:\
11/27/2019 08:53 <DIR> .
11/27/2019 08:53 <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 871243935744 bytes free
Z:\[]>md zz
Z:\[]>md zz;
A subdirectory or file zz already exists.
Z:\[]>md "zz;"
Z:\[]>dir
Volume in drive Z has no label.
Volume Serial Number is CAC7-078B
Directory of Z:\
11/27/2019 08:54 <DIR> .
11/27/2019 08:54 <DIR> ..
11/27/2019 08:54 <DIR> zz
11/27/2019 08:54 <DIR> zz;
0 File(s) 0 bytes
4 Dir(s) 871243935744 bytes free
Z:\[]>cd zz;
Z:\zz;[]>cd ..\zz
Z:\zz[]>cd "..\zz;"
Z:\zz;[]>
The issue has been resolved with the following
Adding -J-Djdk.lang.Process.allowAmbiguousCommands=true to netbeans_default_options= in etc/netbeans.conf
The output from the compile command has not changed, however it now finds the directories???
I use Mathematica 11 and create a project containing two files: a package file named MyPackage.m and the other named run.m.The package file contains just normal functions not in special Mathematica package structure (https://reference.wolfram.com/workbench/index.jsp?topic=/com.wolfram.eclipse.help/html/tasks/applications/packages.html) and the other contains code to get MyPackage.m and use the functions.
(* Package.m *)
myFun[x_String] := Print[x]
...
(* run.m *)
<<"Package.m"
myFun["Hello,World"]
I put these two files into one directory and ensure that the $path contains the directory path. But, when I run wolframscript -file ./run.m -print all, it complains $Failed.
The question is: how to import another file when using wolframscript? It seems cannot find the destination file even they are in the same directory.
I use Mathematica 11 and run wolframscript in Ubuntu server where I have installed the latest Free CDF Player.
I encountered no problem running your script. Also, -print all appears to be superfluous.
C:\Users\chrisd\Documents\test>dir
Volume in drive C is Windows7_OS
Volume Serial Number is 102A-B66B
Directory of C:\Users\chrisd\Documents\test
14/09/2017 15:03 <DIR> .
14/09/2017 15:03 <DIR> ..
14/09/2017 14:59 29 Package.m
14/09/2017 14:59 38 run.m
2 File(s) 67 bytes
2 Dir(s) 215,590,776,832 bytes free
C:\Users\chrisd\Documents\test>wolframscript -file run.m -print all
Hello,World
C:\Users\chrisd\Documents\test>type Package.m
myFun[x_String] := Print[x]
C:\Users\chrisd\Documents\test>type run.m
<<"Package.m"
myFun["Hello,World"];
C:\Users\chrisd\Documents\test>
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
This does not work:
del "folder\*.dll.config"
However, it does work without specifying a folder
cd folder
del "*.dll.config"
Why?
PS. Also, any workarounds? (beside the one mentioned - changing current dir and then going back)
EDIT: I'm an idiot I had a typo in my code, voting to close my own question now.
On my Windows 10, it works:
C:\>dir folder
Volume in drive C is SYSTEM
Directory of C:\folder
30.03.2017 14.33 <DIR> .
30.03.2017 14.33 <DIR> ..
29.03.2017 13.33 549.341 my.dll.config
29.03.2017 13.33 549.341 my.foo.bar
2 File(s) 1.098.682 bytes
2 Dir(s) 363.317.178.368 bytes free
C:\>del "folder\*.dll.config"
C:\>dir folder
Volume in drive C is SYSTEM
Directory of C:\folder
30.03.2017 14.33 <DIR> .
30.03.2017 14.33 <DIR> ..
29.03.2017 13.33 549.341 my.foo.bar
1 File(s) 549.341 bytes
2 Dir(s) 363.317.809.152 bytes free
C:\>
However, your misspelling of the error message in the comment above made me check something.
It may be completely irrelevant in your case, but sure enough, if I misspell the folder name, I get precisely the error you mentioned:
C:\>dir folder
Volume in drive C is SYSTEM
Directory of C:\folder
30.03.2017 14.33 <DIR> .
30.03.2017 14.33 <DIR> ..
29.03.2017 13.33 549.341 my.dll.config
29.03.2017 13.33 549.341 my.foo.bar
2 File(s) 1.098.682 bytes
2 Dir(s) 363.317.248.000 bytes free
C:\>del "dolder\*.dll.config"
The system cannot find the file specified.
C:\>
You can use thepushd and popd commands like:
pushd folder
del "*.dll.config"
popd
This way you move to the desire location, erase all .dll.config files and return to the previous location.
Windows 7/NTFS and later has both symbolic links and junctions, and they are subtly different. (See this excellent set of posts). For logging (and debugging) purposes, I need to be able to resolve the target of a junction on a remote file server. There have been some posts on this topic, but they apply to resolving a junction as the local machine see it.
On \\FileServer, we have a directory G:\Shared that is shared out as PublicShare, so it apears on the network as \\FileServer\PublicShare. Within that directory are sub-directories G:\Shared\SubDir1 and G:\Shared\SubDir2. Also within that directory is a junction G:\Shared\Junc that points to either G:\Shared\SubDir1 or G:\Shared\SubDir2. (The target can change.) Thus, on \\FileServer, one sees
\\FileServer\PublicShare\SubDir1
\\FileServer\PublicShare\SubDir2
\\FileServer\PublicShare\Junc
On a client machine where \\FileServer\PublicShare is mounted (mapped in Windows lingo) as M:\, one thus sees M:\SubDir1, M:\SubDir2, M:\Junc. If, on that client machine, you open a console (cmd.exe) and do dir M:\, Windows gives a nice listing which shows that M:\Junc is a junction and includes the target, G:\Shared\SubDirX, of the junction.
M:\>dir
Volume in drive M is XXXXXXXXX
Volume Serial Number is XXXX-XXXX
Directory of M:\
09/05/2014 07:30 PM <DIR> .
09/05/2014 07:30 PM <DIR> ..
09/05/2014 01:36 PM <JUNCTION> Junc [G:\Shared\SubDir1]
09/06/2014 12:55 PM <DIR> SubDir1
09/05/2014 05:15 PM <DIR> SubDir2
0 File(s) 0 bytes
3 Dir(s) 1,895,493,492,736 bytes free
M:\>
Thus, the target of such a junction is clearly available to a client. Does anyone know how to obtain this information programatically, e.g. which system api to call??? Thanks.
This does the trick:
fsutil reparsepoint query "M:\Junc"
and it seems very reliable.
If you don't want to parse the output of C:\Windows\System32\fsutil.exe, you could simply use DIR:
for /f "usebackq delims=[] tokens=2" %i in ( `dir M:\^|findstr JUNCTION` ) do set RES=%i
Notes:
M:\: you need to display the subfolders (and junctions) of the parent folder of the JUNCTION (in this case: M:\)
findstr: if you have several junctions and want to resolve a specific one, add a |findstr foldername to isolate the right line,
delims=[]: that will divide the output 09/05/2014 01:36 PM <JUNCTION> Junc [G:\Shared\SubDir1] into 3 tokens:
09/05/2014 01:36 PM <JUNCTION> Junc
G:\Shared\SubDir1
"<empty>"
tokens=2: only the second token ("G:\Shared\SubDir1") is of interest
%i: if you run that command in a .bat script, double the '%': %%i in and res=%%i
Just when I'd thought I'd seen it all with Windows path issues, I've now encountered a case that only fails when '/' (forward-slash) is used as the path separator is used:
C:\temp\tcbugs>mkdir "dir1 with spaces"
C:\temp\tcbugs>echo hi > "dir1 with spaces"\foo.txt
C:\temp\tcbugs>type "dir1 with spaces\foo.txt"
hi
C:\temp\tcbugs>type "dir1 with spaces/foo.txt"
The system cannot find the file specified.
What is particularly interesting about this is that it appears to be specific to the cmd.exe shell and doesn't occur in PowerShell (nor presumably in the win32 API):
PS C:\temp\tcbugs> type 'dir1 with spaces/foo.txt'
hi
Another point of interest is that changing directories with 'cd' and using '/' used as a path separator with cmd.exe does work:
C:\temp\tcbugs>mkdir dir2_no_spaces
C:\temp\tcbugs>cd ./dir2_no_spaces
C:\temp\tcbugs\dir2_no_spaces>cd ..
Yet, I can't find any reference to this particular problem anywhere online nor in MSDN's commonly cited documentation:
Naming Files, Paths, Namespaces
Which leads me to ask: why does this happen, and is there a definitive source which documents this quirk?
UPDATE:
dbenham points out that the problem is present regardless of whether spaces are in a directory name, so removed reference to it in the title and question body. Also added an example of 'cd ./' that works, while other commands don't.
Edited to remove opinion
Whether or not Windows CMD.EXE is supposed to support forward slashes in paths, the fact is sometimes it works, sometimes it doesn't, and sometimes it appears to work but gives the wrong result - AKA a bug.
It's time for some experiments :-)
All tests were run on Vista
C:\>md "c:/temp/"
C:\>REM The forward slash works with MD!
C:\>echo hello world 1>>"c:/temp/test.txt"
C:\>REM Redirection works with forward slashes!
C:\>type "c:\temp\test.txt"
hello world
C:\>REM Of course TYPE works with back slashes
C:\>type "c:/temp/test.txt"
The system cannot find the file specified.
C:\>REM But forward slash version fails
C:\>type "c:/temp\test.txt"
hello world
C:\>REM But TYPE works with forward slash as long as last slash is back slash
C:\>dir "c:/temp/test.txt"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
File Not Found
C:\>REM Note how DIR lists the directory with a \, yet fails to find any files
C:\>dir "c:/temp/*"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
File Not Found
C:\>REM DIR Still fails with forward slashes
C:\>dir "c:/temp/"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
05/09/2012 09:58 PM <DIR> .
05/09/2012 09:58 PM <DIR> ..
05/09/2012 09:58 PM 13 test.txt
1 File(s) 13 bytes
2 Dir(s) 337,001,615,360 bytes free
C:\>REM But forward slash works if no file is specified!
C:\>dir "c:/temp\test.txt"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
05/09/2012 09:58 PM 13 test.txt
1 File(s) 13 bytes
0 Dir(s) 337,001,615,360 bytes free
C:\>REM And DIR works with forward slash as long as last slash is back slash
C:\>REM Now add another folder to the path hierarchy
C:\>md "c:/temp/temp/"
C:\>REM Still can create folder using forward slashes
C:\>copy "c:/temp/test.txt" "c:/temp/temp/"
The system cannot find the file specified.
0 file(s) copied.
C:\>REM Failed to copy with forward slashes
C:\>copy "c:/temp\test.txt" "c:/temp/temp/"
1 file(s) copied.
C:\>REM But forward slash works if last slash before file name is back slash
C:\>REM Rerun some past tests
C:\>type "c:/temp/test.txt"
The system cannot find the file specified.
C:\>REM Good - it still fails
C:\>dir "c:/temp/test.txt"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
05/09/2012 09:58 PM 13 test.txt
1 File(s) 13 bytes
0 Dir(s) 337,001,615,360 bytes free
C:\>REM What is going on?! :( Why did that seem to work now?
C:\>REM More on that later.
C:\>REM Now test the new folder
C:\>type "c:/temp/temp/test.txt"
The system cannot find the file specified.
C:\>REM Forward slashes still fail with TYPE
C:\>type "c:/temp/temp\test.txt"
hello world
C:\>REM But forward slash still works as long as last slash is back slash
C:\>dir "c:/temp/temp/*"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp\temp
File Not Found
C:\>REM Again, forward slashes fail, but directory path is listed properly
C:\>dir "c:/temp/temp/"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp\temp
05/09/2012 09:58 PM <DIR> .
05/09/2012 09:58 PM <DIR> ..
05/09/2012 09:58 PM 13 test.txt
1 File(s) 13 bytes
2 Dir(s) 337,001,615,360 bytes free
C:\>REM And again it works if no file is specified
C:\>dir "c:/temp/temp\test.txt"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp\temp
05/09/2012 09:58 PM 13 test.txt
1 File(s) 13 bytes
0 Dir(s) 337,001,615,360 bytes free
C:\>REM Again forward slashes work as long as last slash is back slash
Here is a case that clearly demonstrates a bug.
c:\>dir /s /a-d temp
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
05/10/2012 08:01 AM 13 test.txt
1 File(s) 13 bytes
Directory of c:\temp\temp
05/10/2012 07:57 AM 10 test.txt
1 File(s) 10 bytes
Total Files Listed:
2 File(s) 23 bytes
0 Dir(s) 337,325,191,168 bytes free
c:\>REM Note the different file sizes found in each directory
c:\>dir "c:/temp/test.txt"
Volume in drive C is OS
Volume Serial Number is EE2C-5A11
Directory of c:\temp
05/10/2012 07:57 AM 10 test.txt
1 File(s) 10 bytes
0 Dir(s) 337,325,191,168 bytes free
c:\>REM It is listing the wrong file!
One can debate whether Windows CMD is "supposed" to support forward slashes. But that last result is a bug! Even if there is operator error in using a forward slash, Windows should not give that result.
Wie had some strange behaviour with slash to and we traced it down to the fact, that a path with a leading slash isn't seen as an absolute path, so
C:\>cd /temp
C:\temp>rem works we are in the root directory
C:\temp>cd /temp
Das System kann den angegebenen Pfad nicht finden.
C:\temp>rem does't work but
C:\temp>cd \temp
C:\temp>rem \ indicates absolute path
C:\temp>cd ..
C:\>cd /temp
C:\temp> cd /ca
C:\temp\CA>rem qed
Perhaps it explains also the bug stated above - im not clear, at which directory the commands are executed.
I am not sure why the '/' is working in PS. Back to the history, DOS was based on UNIX and it is a small set of UNIX. In UNIX the path separator is '/', while in DOS it is '\'. I worked on some Windows and DOS apps before. In order to convert some UNIX pattern like commands or path and make sure they are valid DOS command or path, I wrote a small converter to transform '/' to '\' like this:
string fileNameFromWeb;
...
string windowsFile = fileNameFromWeb.repleace("/", #"\");
You may add this feature to tolerant '/' in your app in case of accessing to files in Windows. I guess PS may have this type converter to allow command or path using '/' or '\', or Windows will take '/' in file name.