Reputation: 25
strcpy(strng, "cd.. ");
strcat(strng, "& copy %cd%\\bin\\");
strcat(strng, file);
strcat(strng, " %cd%\\txt");
system( strng );
Greetings, I've been working on file handling for C in windows, and unfortunately, I have run into this odd pickle. While I have gotten most of my code to work, including the issue I'm running into previously, "cd.." doesn't seem to be correctly going to the parent directory. Is there any word on why [or a quick and similar fix]?
Prior in the program it works in this short line of code:
if (numLog > 8) {
system("cd.. & cd txt & del *.txt");
return errinit(); };
Upvotes: 0
Views: 47
Reputation: 80023
Your effective string is
cd..& copy %cd%\bin\file %cd%\txt
Batch parses the entire line, then executes it, so %cd%
is evaluated as its value before the cd ..
is executed.
copy %cd%\..\bin\file %cd%\..\txt
should do what you appear to want.
Upvotes: 4