0

I have a script that appends the date and time to all files in a folder. I use the script like this...

bash append_date.sh /home/user/Documents/Podcasts/

and that will append the date to all files in the /home/user/Documents/Podcasts/ folder

Problem is that if there is a whitespace in the directory tree it fails to do anything. ie

bash append_date.sh /home/user/Documents/My Stuff/

I have tried passing the following, but that does not work

bash append_date.sh /home/user/Documents/My\ Stuff/

How do I get this script to play nice with whitespaces?

Many thanks for any help.

Entropy1024
  • 7,847
  • 9
  • 30
  • 32
  • 2
    Using backslash to escape the white space is correct but your question cannot be answered as long as we do not know how the code of `append_date.sh` looks like. – axiac Jan 27 '23 at 09:25
  • the problem must be fixed in `append_date.sh` which probably uses unquoted `$1` argument. that's why whitespaces are a bad idea as most scripts don't expect them – Jean-François Fabre Jan 27 '23 at 09:26

0 Answers0