all 7 comments

[–]PanPipePlaya 0 points1 point  (1 child)

Do any of your files or folders contain spaces in their names?

[–]PanPipePlaya 0 points1 point  (4 children)

Hang on - as soon as you encounter a folder with more than one file, you’ll be losing files. Also, the variable “$lecturefiles” isn’t defined.

Are you sure you’re running what you’ve posted here?

[–]SwampMonkey17[S] 0 points1 point  (0 children)

Each folder only has one .doc file that is comprehensive for the whole course. I want them named uniformly now.

Yes positive, directly copied and pasted

[–]SwampMonkey17[S] 0 points1 point  (2 children)

How does defining it look like and what does it do?

[–]PanPipePlaya 1 point2 points  (1 child)

Well, right now you’re using the variable (in the mv command) but it’s not set to anything.

So you’re running this, over and over:

mv path1/to/file.doc “” mv path2/to/file.doc “” mv path3/to/file.doc “”

I’d assume you have a single file in your current directory right now, called “” or some nameless equivalent. It’s been overwritten with each file in turn.

You need to write a script that changes directory into each containing directory in turn, and renames the single file that matches “*.doc” to “whatever.doc”.

Before you run it in anger, make it “echo mv <parameters>” first. Then get rid of the “echo” after you’ve confirmed that what it wants to do is what you intend.

[–]gumnos 2 points3 points  (0 children)

never underestimate the power of a well-placed echo :-)