System cannot find the file specified while copying through CMD - c

In my C program, I execute a system command to copy files from my downloads folder to a folder in desktop, the program works on .mp3 files.
The problem is that my program copies all the .mp3 files successfully from other folders except a specific folder for a reason I don't know why. I Checked the command being executed and it shows no syntax or file name errors.
The command that causes (system cannot find the file specified) error:
system("copy \"C:\\Users\\Mac\\Downloads\\test\\01 Andrew Bayer - Counting The Points.mp3\"
\"c:\\users\\Mac\\desktop\\AVB\"");
Please help me to spot the reason that causes this error in spite that the file name and path of the file is correct, and only the files in this folder(test) causes this error.
Note:
The files I'm trying to copy are downloaded from a torrent, if this may help.

A few thoughts:
Perhaps the path to your file is too long. Try to copy the folder to the root of your disk and retry the command. Or use subst to connect a drive letter to a path.
There could be an issue with NTFS rights. Go to the security settings of the Downloads folder. Check the permissions and enable the checkbox option to replace security on all subfolders and files (remove explicitly set permissons of the child items).
Try renaming the file to A.mp3, I'm not sure if it is possible, but the file name could contain weird unicode characters?

Related

How to specify in windows batch file to open spyder, change the working directory and run a script?

I have created a windows batch file to run a code which is located in a particular folder. However, I am running the batch file but it does not work. What I want it to do is:
Change working directory in Spyder (Spyder is already openned so I don't want it to open it first)
Run the script I want to execute
Basically, the script I am running is plotting a bunch of graphs and all the files needed to create this are located in the working directory.
#echo off
"C:\Users\Mason\Desktop\WinPython-64bit-2.7.6.4\spyder.exe"
chdir /D "F:\optimisation"
"F:\optimisation\plot.py"
pause
The batch file runs fine without any errors, but nothing happens in Spyder e.g. it doesn't change the working directory and neither executes the code.
I'd suggest
#echo off
setlocal
chdir /D "F:\optimisation"
"C:\Users\Mason\Desktop\WinPython-64bit-2.7.6.4\spyder.exe" "F:\optimisation\plot.py"
pause
That is, switch to the required directory, having set a local environment (this restores the original environment when the batch terminates).
Then run the spyder executable, providing it with the name of the file. It would be normal practice to use this structure to provide a significant filename to an executable (eg notepad fred,txt)
Since the current directory when spyder runs is f:\optimisation, it is probably not necessary to specify the entire path in spyder's argument.
Note this is all just speculation using normal practice. I have no experience of spyder- in fact, this is the first I've heard of it.

Batch Script responds with "Error opening script file" when opening FTP file

I want to use a Batch file to upload files from a folder on my computer.
When I call the FTP Script to do the upload:
FTP -v -i -s:ftp.txt
or
FTP -v -i -s:c:\path\to\file\ftp.txt
Neither of those works, and instead
Error opening script file: ftp.txt
is returned.
Strange thing is, that the exact same script is being executed without problems on another computer.
Opening the batch file with admin-rights does not help. I'm running Windows 10.
Edit: The ftp.txt looks like this:
open ##host##
##user##
##password##
lcd c:\local\path\
cd path/on/server/
binary
mput "*.xxx"
disconnect
bye
Make a new, empty file with echo >ftp.test and try with that file.
If that gives you the same error, you'll need to look at your execution environment (look at set and the process owner of cmd.exe). It's also possible that the ftp command is being run as a user that doesn't have access to that file.
If you don't get an error then it's probably either a file-permissions or special-character issue with ftp.txt. Retyping the same content into a different file will get around those issues. Remember not to copy/paste because you could accidentally copy invisible special characters that you're trying to avoid.
I would like to add to this conversation since there have been a lot of views and no solution. I had the same response and it wasn't a permissions issue. It was also no the text file that was the issue because it never technically reached the text file. It was the path to the text file. The following for me didn't work. I had to put quotations around the path even though there were no spaces to confuse the command line.
What you tried:
FTP -v -i -s:c:\path\to\file\ftp.txt
What I tried and worked. (I didn't need to use -v, mine works without it)
FTP -i -s:"c:\path\to\file\ftp.txt"
Running the file acted normal for me. My issue was trying to run the batch file through Windows Task Manager. Somehow, this was causing it to lose the text file somehow. I hope this helps anyone else who reads this thread.
I had to put the .txt file path in the "Start In" section for it to work in Windows Task Manager. No problems since.

.bat file that deletes 2 specific files on a specific directory

As the tile says. I need a .bat file to automatically delete 2 files on my C on a specific directory everytime I execute it.
I'm noob and don't know the commands :(
Try this :
del "C:\TEST\*.TXT"
For this example it will delete all files under TEST Folder with the .TXT extension so it depends on the extensions of the files , you can merely mention their names with their right extensions and it will work !
(Save the command in a .bat file and execute it as Administrator)

Program opened with batch file won't work

At work I use a bunch of different programs that are located in many different folders that I have to open when I get here. So I've created a batch file that opens all of them for me.
I've run into an issue with one program that's located on a shared network. In my batch file I put
START "" "\\server\path\program.exe"
It loads the program but when I try to navigate the program is doesn't work. I run into an exception error that says it can't find a file on the C drive. But when I load the same program from the folder without the batch file, it works just fine. Any idea what's causing this?
Try specifying the working folder:
START "" /D "\\server\path" "\\server\path\program.exe"
It's documented in the output of start /?.

How to customize shortcut in compressed file to run exe from current directory?

How to customize shortcut in compressed file to run exe from current directory? For example, i want to put compress two file inside winrar first is program.exe and the second is shortcut to that program, if i compress that in rar extension, and copy compressed file in other directory and open with winrar and run shortcut, i get nothing. So my question is what code to put in shortcut to run program.exe regardless in which directory will be compressed file extract?
You get nothing because there is no program to run. A compressed file isn't a filestore from which files can be run. When you "run" a file from a compressed file, the OS is actually extracting that file to a temp folder and then running it. When you tru and run the shortcut, its being extracted, but the temp folder in which it was extracted doesn't contain the actual .exe you're trying to launch, so nothing happens.
As to how you achieve what you want, I have no idea, but would not be suprised if it was not possible. If you're running the exe from a compressed file, why do you need the shortcut? Why not just click the .exe?

Resources