Batch renaming txt files to match folder, all in same directory?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
In ~/Desktop/a/ , I have folders (with names that have spaces) and txt files in the form:
100 description, 100_notes.txt,
200 description, 200_notes.txt
What I would like:
100 description, 100 description.txt,
200 description, 200 description.txt
This is the script so far:
#!/bin/bash
cd ~/Desktop/a/
for i in *; do
mv "$i/$f%.txt” "$i.txt”;
done
I'm trying it with test files, and it returns error:
mv: rename 100 description/” 100 to description.txt”: No such file or directory
bash
New contributor
add a comment |
up vote
0
down vote
favorite
In ~/Desktop/a/ , I have folders (with names that have spaces) and txt files in the form:
100 description, 100_notes.txt,
200 description, 200_notes.txt
What I would like:
100 description, 100 description.txt,
200 description, 200 description.txt
This is the script so far:
#!/bin/bash
cd ~/Desktop/a/
for i in *; do
mv "$i/$f%.txt” "$i.txt”;
done
I'm trying it with test files, and it returns error:
mv: rename 100 description/” 100 to description.txt”: No such file or directory
bash
New contributor
Looks like you are using the wrong quotes. You appear to have the correct open quote and the wrong close quote (both should be the same).
– Cupcake Protocol
12 mins ago
What is100 description, 100_notes.txt,
the name of? It's unclear what things are named here. Is the last comma part of the filename name?
– Kusalananda
3 mins ago
@CupcakeProtocol That's an immediate problem, but also notice that they are using an unset variablef
in themv
command.
– Kusalananda
1 min ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
In ~/Desktop/a/ , I have folders (with names that have spaces) and txt files in the form:
100 description, 100_notes.txt,
200 description, 200_notes.txt
What I would like:
100 description, 100 description.txt,
200 description, 200 description.txt
This is the script so far:
#!/bin/bash
cd ~/Desktop/a/
for i in *; do
mv "$i/$f%.txt” "$i.txt”;
done
I'm trying it with test files, and it returns error:
mv: rename 100 description/” 100 to description.txt”: No such file or directory
bash
New contributor
In ~/Desktop/a/ , I have folders (with names that have spaces) and txt files in the form:
100 description, 100_notes.txt,
200 description, 200_notes.txt
What I would like:
100 description, 100 description.txt,
200 description, 200 description.txt
This is the script so far:
#!/bin/bash
cd ~/Desktop/a/
for i in *; do
mv "$i/$f%.txt” "$i.txt”;
done
I'm trying it with test files, and it returns error:
mv: rename 100 description/” 100 to description.txt”: No such file or directory
bash
bash
New contributor
New contributor
edited 5 mins ago
Rui F Ribeiro
38k1475123
38k1475123
New contributor
asked 32 mins ago
user10630009
154
154
New contributor
New contributor
Looks like you are using the wrong quotes. You appear to have the correct open quote and the wrong close quote (both should be the same).
– Cupcake Protocol
12 mins ago
What is100 description, 100_notes.txt,
the name of? It's unclear what things are named here. Is the last comma part of the filename name?
– Kusalananda
3 mins ago
@CupcakeProtocol That's an immediate problem, but also notice that they are using an unset variablef
in themv
command.
– Kusalananda
1 min ago
add a comment |
Looks like you are using the wrong quotes. You appear to have the correct open quote and the wrong close quote (both should be the same).
– Cupcake Protocol
12 mins ago
What is100 description, 100_notes.txt,
the name of? It's unclear what things are named here. Is the last comma part of the filename name?
– Kusalananda
3 mins ago
@CupcakeProtocol That's an immediate problem, but also notice that they are using an unset variablef
in themv
command.
– Kusalananda
1 min ago
Looks like you are using the wrong quotes. You appear to have the correct open quote and the wrong close quote (both should be the same).
– Cupcake Protocol
12 mins ago
Looks like you are using the wrong quotes. You appear to have the correct open quote and the wrong close quote (both should be the same).
– Cupcake Protocol
12 mins ago
What is
100 description, 100_notes.txt,
the name of? It's unclear what things are named here. Is the last comma part of the filename name?– Kusalananda
3 mins ago
What is
100 description, 100_notes.txt,
the name of? It's unclear what things are named here. Is the last comma part of the filename name?– Kusalananda
3 mins ago
@CupcakeProtocol That's an immediate problem, but also notice that they are using an unset variable
f
in the mv
command.– Kusalananda
1 min ago
@CupcakeProtocol That's an immediate problem, but also notice that they are using an unset variable
f
in the mv
command.– Kusalananda
1 min ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
user10630009 is a new contributor. Be nice, and check out our Code of Conduct.
user10630009 is a new contributor. Be nice, and check out our Code of Conduct.
user10630009 is a new contributor. Be nice, and check out our Code of Conduct.
user10630009 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481050%2fbatch-renaming-txt-files-to-match-folder-all-in-same-directory%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Looks like you are using the wrong quotes. You appear to have the correct open quote and the wrong close quote (both should be the same).
– Cupcake Protocol
12 mins ago
What is
100 description, 100_notes.txt,
the name of? It's unclear what things are named here. Is the last comma part of the filename name?– Kusalananda
3 mins ago
@CupcakeProtocol That's an immediate problem, but also notice that they are using an unset variable
f
in themv
command.– Kusalananda
1 min ago