Jump to content
View in the app

A better way to browse. Learn more.

Obsidian Forum Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

how could i write a shell script that will recursively descend through a directory structure, checking all entry names for spaces, and when a name is encountered that contains one or more spaces, replace each space with an underscore character? if anyone can help me, i will post a smilie in your honour. :thumbsup:

  • Author

can anyone help me? please.

Not that I can help, but hello Mr Pantsworth.

kirottu said:
I was raised by polar bears. I had to fight against blood thirsty wolves and rabid penguins to get my food. Those who were too weak to survive were sent to Sweden.

 

It has made me the man I am today. A man who craves furry hentai.

So let us go and embrace the rustling smells of unseen worlds

  • Author

not to spam, but to reply and keep this topic near the top... hello.

Perhaps this is good evidence that no one in this video game developer fan forum is a competent nix shell script writer? I would have known a couple of years ago, or at least I would have known where to look to get an answer, but I stopped working with them and I've forgotten it all. I would think you would need to know a bit about the ls command (how to ls the nth file in a directory, basically) and how to pick out spaces from a string (I might do that in a slightly more sophisticated programming language like fortran or C rather than in-shell). So you feed the nth filename into a small program that puts the string into an array and then have a while loop that switches all of the empty cells into underscores, then send the new string back to the shell script to use with a rename command on the original file (using the mv program, I think?). There's probably a way to do it all in-shell but I don't know it.

#!/bin/bash

 

for i in "`ls -d */`"; do

newName="`echo -n $i | tr -s [:space:] "_"`"

mv "$i" "$newName"

done

 

Am stumped in recursion

 

Research.

  • Author

thank you very much. ;)

lame error correction:

 

#!/bin/bash

 

for i in */; do {

newName=`echo -n "$i" | tr -s [:space:] "_"`

mv "$i" "$newName"

 

}

done

#!/bin/bash

function RenameFiles
{
for i in *
do
if [[ -d "$i" ]]
then
 cd "$i"
 RenameFiles 
 cd ..
elif [[ -f "$i" ]]
then
 newName="`echo -n "$i" | tr -s [:space:] "_"`"
 mv "$i" "$newName"
fi
done
}

RenameFiles

 

It still needs some work, but this will rename the files recursively.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.