我們一直在捕獲文件並將其發送到REST服務器,並將它們從工具欄保存到PNG擴展中,現在有近50萬個文件。需要遞歸BASH腳本遍歷文件夾並使用通配符
最近我們發現他們實際上已經保存爲base64流文件而不是PNG格式。
我有一個python腳本,可以轉換它們,但不遞歸和connot使用通配符。
ImageMagick說base64文件太大(最大5K),因此無法進行轉換。
IE; /bin/base64-to-png.py <base64_file_name>.png <output_name.png>
目錄路徑/ mnt/s3/pages /其中「pages」有幾千個編號的文件夾。
IE; /mnt/s3/pages/100
"pages" subfolders are never more than 1 folder deep.
The files are typically 5540_thumb.png, 5540_snapshot.png and 5540_crop.png
where the 5540 is the capture number.
我需要一個bash腳本包裝,使其recusive防空火炮的文件夾,複製所有原稿的備份文件(filename.b64),並通過通配符正確的路徑/名到python腳本,轉換的文件,並留下輸出文件在相同的文件夾中,然後使用mogrify壓縮它們。
IE; base64-to-png.sh *_snapshot.b64 *_snapshot.png <compression number>
should
cp <file_name.png> <file_name>.b64
/bin/base64-to-png.py <file_name.png> <file_name.png>
mogrify -quality <compression number> -format png <file_name.png>
我相信在行中'$ FINDEXT'應該雙引號,對不對? –
它不一定是。 – Rohan
Rohan你的腳本工作正常,我只需要將FINDEXT =「*。png」更改爲命令行變量,這只是因爲需要將縮略圖文件壓縮到不同的比率 - 很多謝謝,這非常有幫助。 – user1213320