I am writing a batch file that encrypts/compresses and unencrypts/decompresses a file. When the user chooses to unencrypt/decompress, the program does unencrypt it, but it does not decompress it, and I cannot figure out why.
Here is the section in question:
SET /P FILEPATH=Please enter entire filepath of the file you wish to decompress and unencrypt:
ECHO
SET /P UNENCRYPTED=Please enter filepath of the file you wish to decompress and unencrypt, but without the final extension. For example, filepath.backup.zip.aes becomes filepath.backup.zip:
aescrypt.exe -d %FILEPATH%
FOR %%F IN (%UNENCRYPTED%) DO SET FILE_PATH=%%~dpF
FOR %%F IN (%UNENCRYPTED%) DO SET FILENAME=%%~nxF
cd %FILE_PATH%
TAR -xf %FILENAME%
I tried first to strip filename.backup.zip.aes of its last extension so I could unzip that by doing this:
FOR %%F IN (%FILENAME%) DO SET UNENCRYPTED=%%~dpnF
TAR -xf %UNENCRYPTED%
Then I tried to unzip that, but it didn’t work.
After that I tried taking the .zip extension off of UNENCRYPTED and putting it back on in the tar command like this:
FOR %%F IN (%FILENAME%) DO SET UNENCRYPTED=%%~dpnF
FOR %%F IN (%UNENCRYPTED%) DO SET NOEXTENSION=%%~dpnF
TAR -xf %NOEXTENSION%.zip
but I got the same result.
Finally I decided to prompt the user a second time for the filepath without the last extension, as shown in the current code, but it doesn’t work either. If anyone can point me to the problem I would be beyond grateful.
Noah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2