Windows 'move' command's /y not overriding destiation file, failing with an error: file already exists - wine

In wine and wineconsole when I try and move a file with the following command:
move /Y "file" "destination" I get the following error:
File already exists
and the file is not replaced. According to the windows help page http://technet.microsoft.com/en-us/library/bb490935.aspx /y should suppress the prompt asking if you wish to override the file, which it does, and also overwrite the file, which it fails at.
If I don't use /y it prompts me, after responding yes the file is overwritten. Can someone confirm the move command with /y is broken in wine (v1.6) and if so offer any suggestions while still using the move command.

As a temporary fix I perform a del /f/q on the destination before I move the file.

Related

How do I delete node_modules folder quickly?

When I want to delete a node_modules folder it takes ages when I delete it using Windows Explorer. How do I delete faster?
I use to have the same issue, taking hours to achieve the deletion until I found this workaround:
Select the node_modules folder. Do this with the file explorer.
Open Powershell as admin: press Alt+F, then S, then A.
Wait and accept to open Powershell as admin
Paste this command and press Enter: del /f/q/s *.* > nul.
WARNING
Please be sure to be in the folder node_modules. I mean, that the terminal path ends with ...\node_modules.
In the above command, we use the /f switch to force the deletion of read-only files. The /q switch enables quiet mode. The /s switch executes the command for all files in any folder inside the folder you’re trying to remove. Using *.* tells the del command to delete every file and > nul disables the console output improving performance and speed.
Wait for the process to take action.
Now go up one level in the directory with cd...
Finally use this command to delete the node_modules folder rmdir /q/s node_modules
In the above command, we use the /q switch to enable quiet mode, the /s switch to run the command on all the folders, and node_modules is the variable you need to specify to delete the folder you want.
If you get an error with Powershell try other terminals as administrator like Windows Terminal, Command Prompt (cmd) or third party terminals like ConEmu. I made this steps with Cmder and all the deletion was done in just 5 minutes. Off course this duration is variable according to the size of the folder.
References:
pureinfotech.com
ConEmu
Cmder
From you project folder use following command to delete it:
rd .\node_modules\ /s /q

CygWin cmd "source" and renaming with "mv"

I am a bit curious about CygWin command source and renaming with mv.
When I run in source file cmd mv and would rename some file in my computer, it renames files well, but unhappily it puts at the end of name also the cryptic character.
f.e.: 1A6CSAB000A1_51D9.pdfand in this case, my computer isn´t able to open the file.
But when I run it without cmd source (and source file), just with
mv A.phd.1 B.phd.1
in CygWin, it works well and rename files without cryptic character.
Any idea how to deal with this issue?
Thanks in advance and sorry, if there is similar question, I didn´t find it.
Gabi

Linux commands within bat file - Aliasing

I seem to be having an issue.
I'm trying to write a batch file that uses Linux commands such as rm, mv, clear, and cat within a Windows batch file, but the catch is I can't seem to figure out what I need to do in order for the Windows command line to recognize that when I type in mv I want it to move a file for me, or rm to remove a file of course.
So far all I have figured out is that I could possibly use __DOSKEY__ but it doesn't work in batch files or with parameters (doh!). Thus, all I have gotten so far is:
#echo off
mv dummy.txt
Now my question is how do I get the Windows command line to recognize that mv = move ? Everytime I run the file it just gives me a blank command line.
I know this may sound stupid but my experience is more on the Linux side of the command line than the Windows side, and any help would be greatly appreciated!
Internal cmd commands cannot be aliased. For external commands, you could create hardlinks, but "move" for example is an internal command.

VisualStudion 2012: Post build Events

In my project I have got following post-build Event:
xcopy "$(TargetDir)Data" "$(ProjectDir)Data" /Y /I
After the run has ended the program copies the files. But if in TargetDir/Data is a complete NEW file, this event does not copy the new file to ProjectDir/Data.
but I would like to have this new files copied to TargetDir/Data. How do I achieve this?
Thanks for help!
"Data" sounds like a directory, not a file. You'll have to create it first. You also appear to have reversed the arguments. Fix:
if not exist "$(TargetDir)Data" mkdir "$(TargetDir)Data".
xcopy "$(ProjectDir)Data\*.*" "$(TargetDir)Data" /Y /I /D
If you in fact meant to copy back to the project directory, very unusual, then just swap TargetDir and ProjectDir in the above snippet.

Zip batch command and Excel

I have many excel files that I need zipped into each of their own zip folders. I thought I had this ironed out, but I have co-workers coming back to me saying that they cannot open the excel file because it has become corrupted. I went back and checked the original file, and it opens up just fine. But when I open up the same version of the file that was zipped, I too get the corrupted error. I'm on Office 2010, which is able to repair it, but my co-workers are all Office 2007 which does not seem to be able to fix the file. My batch code is as follows:
for /r %%X in (*.xlsm) do "C:\Program Files\7-Zip\7z.exe" a -tzip "%%~nX" "%%X"
I think you might be using a wrong value as the first parameter to the 7zip executable. According to the documentation on FOR:
%~nI - expands %I to a file name only
And according to the 7zip documentation:
You can use the "a" command with the single letter a. This command stands for 'archive' or 'add'. Use it to put files in an archive. You have to specify the destination archive, and the source files (in that order).
So, using your script with an example file, it seems to me that your command line becomes:
"C:\Program Files\7-Zip\7z.exe" a -tzip "somefile.xlsm" "C:\path\to\somefile.xlsm"
Shouldn't the first parameter have a .zip file extension on the end? So the line is modified to look like this:
for /r %%X in (*.xlsm) do "C:\Program Files\7-Zip\7z.exe" a -tzip "%%~nX.zip" "%%X"
As annoying as it is, file extensions actually mean something in Windows. Your previous line was creating a zip file with the .xlsm extension. When people try opening those files, Excel complains (because it's a zip file; not a .xlsm).
#Echo OFF
PUSHD "C:\Program Files\7-Zip" && (
FOR /R "%CD%" %%# in (*.xlms) DO (7z a -tzip "%%~n#.zip" "%%#")
POPD
)
REM Don't worry about the PUSHD command, the %CD% variable isn't expanded, that's the trick.
Pause&Exit
And you can use the dynamic operator * (asterisk) and 7zip -recursive parameter if you want all together in one file:
7z a -r -tzip "ALL.zip" "*.xlsm"
Sorry guys.
It was a false alarm. Turns out it wasn't all of the files, but only a select few. The files were sectioned out by region, and the only ones that were corrupt were the first region. Why? I can only assume that they were corrupted by my original attempts at making a batch file, as all the other files were zipped with the finished batch and thus didn't have errors. So nothing was wrong with my script. Thanks for the help though.

Resources