S
S
Sergey2018-06-18 12:19:35
bash
Sergey, 2018-06-18 12:19:35

rename not working?

Hello.

uname -a
Linux rr-photo 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux

bash --version
GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)

rename --version
/usr/bin/rename using File::Rename version 0.20

There is a program that processes photos (on dotnet), but in jpg it cannot, so a crutch was made by renaming.
There is a menu at #!/bin/bash. Which makes a configuration file for this program and runs it.
At the end of the menu, after all the cycles, it is written:
local rnDIR=/media/photo/photostorage/data;
[ -d $rnDIR/$outputpath/water/ ] && ls $rnDIR/$outputpath/water/ && rename 's/.jpeg/.jpg/g' $rnDIR/$outputpath/water/*.jpeg

There is a check for the presence of a folder, the contents of the folder (this is already for "debugging") and the actual rename itself.
As a result, the output of set -x is:
+ local rnDIR=/media/photo/photostorage/data
+ '[' -d /media/photo/photostorage/data/2222-12-31-testphoto/water/ ']'
+ ls /media/photo/photostorage/data/2222-12-31-testphoto/water/
00000-testphoto-22221231-aa934eb2-9e32-4ecb-bad7-b6aa73e0d229-water.jpeg  00015-testphoto-22221231-5439aea4-beee-42e4-85b7-a4896340893a-water.jpeg  00030-testphoto-22221231-6c503564-2c8f-4c57-a71f-6354b62cebee-water.jpeg
00001-testphoto-22221231-3e98702e-89df-481a-9873-918de74d2b67-water.jpeg  00016-testphoto-22221231-6a4b5cd8-db77-413f-92da-6dd243ca3b28-water.jpeg  00031-testphoto-22221231-119bf512-e287-4625-b427-9d9a7ecb63e4-water.jpeg
00002-testphoto-22221231-8119fd4d-9f6c-40e1-a516-727a45977f75-water.jpeg  00017-testphoto-22221231-bd62df04-2d4d-41fa-a03f-21ff646b2926-water.jpeg  00032-testphoto-22221231-e93d7c60-50f7-41f4-b63f-4a29720d514f-water.jpeg
00003-testphoto-22221231-93de0c6c-4213-4115-a91e-b77ad6a7e639-water.jpeg  00018-testphoto-22221231-f6a5dc63-1778-4f10-a49f-ef696dd041d1-water.jpeg  00033-testphoto-22221231-0aeb1416-8262-4b64-ae75-6c7ec7e4f774-water.jpeg
+ rename s/.jpeg/.jpg/g '/media/photo/photostorage/data/2222-12-31-testphoto/water/*.jpeg'
Can't rename /media/photo/photostorage/data/2222-12-31-testphoto/water/*.jpeg /media/photo/photostorage/data/2222-12-31-testphoto/water/*.jpg: No such file or directory

If you type rename from the terminal, it works.
If you make a separate script file, it works.
And it does not work and I do not understand why he does not see the files in the folder.
During the execution of the "menu" I wrote ls /media/photo/photostorage/data/2222-12-31-testphoto/water/*jpeg | wc - l
The answer was 0, i.e. and ls doesn't see the files.
Maybe they are somehow blocked?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-06-19
@kRosis

All this poop climbed because of
set -f

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question