0

I installed the GNU tar for windows to speed up tar-ing files so I don't have to mess around opening 7zip twice to tar then gzip a file.

To speed up the process even more, I tried to write a send-to batch file that looks like this:

tar -cf %1.tar.gz %1

The command works fine in the terminal (when I open it in my working dir) and would look something like:

tar -cf myfile.tar.gz myfile.txt

However when I run the send-to batch file the input ends up being:

tar -cf C:\path\to\myfile.txt.tar.gz C:\path\to\myfile.txt

I get this error from tar:

C:\path\to\my>tar -cf C:\path\to\my\myfile.txt.tar.gz C:\path\to\my\myfile.txt
tar: Cannot open C:\path\to\my\myfile.txt.tar.gz: Function not implemented
tar: Error is not recoverable: exiting now

I'm not really sure what's wrong here but I'm certain it's not a problem with tar but rather some confusion with paths and file names.

I was wondering if there's a nice and simple way to do this with a batch script (maybe get JUST the file name as an argument rather than the full path) or will I need to do something more elaborate?

0

It seems to me that tar does not accept a full path to the archive being created. You should modify your batch file to cd to the desired folder first, e.g.

cd "%~dp1" 

and then use

tar -cf "%~n1.tar.gz" "%~nx1"

Quotes are used here to accommodate for space-containing names.

  • Perfect! I didn't know about those argument modifiers, thanks! – Southclaws Oct 28 '14 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.