News:

SMF - Just Installed!

Main Menu

base64 decode all files in 1 directory from terminal?

Started by mahesh, Aug 15, 2023, 08:11 AM

Previous topic - Next topic

mahesh

ok here's the command I've been using on individual files, kept in /me/c

    Code:
me@skully:~/c$ sudo base64 --decode docx > docx.docx
.. where for example, docx is a plain text file containing a base64 encoding of an MS Word .docx document.

it spits out the decoded MS Word document as docx.docx which I can then open in a word processor.

I have a raft of text files in the directory, all with random placeholder names like rumple, tug, alvin, ffff, interesting, newts etc..

What I'd like to do is issue one terminal command to go through the directory and base64 decode each and every file, leaving the originals in place, and placing the decodes into their own subdirectory, each with the same filename as the original.

How would I accomplish that?

I guessed at

     Code:
me@skully:~/c$ sudo base64 --decode *  > ~/c/o/*
but it did not work

Could I modify something like this; https://dev.to/equiman/base64-encode...ple-files-2ol1

[edit] - got the code at the above link working.