Auto-rename German Umlaute

Hi!

I want to rename all files (and folders) that are uploaded (via web interface or app) automatically so no “Umlaut” is part of the file (folder) name. (ä --> ae)

Why? Some applications have difficulties with such file names

A nice touch would be to swap blanks for underscores, but thats not crucial.

Any ideas?

Which one?

Changing file and folder names sounds pretty easy at first view. The complexity starts with syncing and naming.
Example: The client is uploading file “älläbätsch” and renames it to “aellaebaetsch”. What to do with the original file on your disk? Renaming as well? Or keeping the new server version and deleting it?

IMHO better check your apps with problems and report issues to their vendors.
In 2020 all applications should be capable of handling german umlaute.
jm2c.

1 Like

The original files should be replaced by the renamed one.

eg GoPros videoediting software an multiple other applications, some of which arent maintained anymore. I regulary transfer files from my cloud to an usb stick to print them on a not printer which isn’t attached to my network, the printer cant read those files.

Nevertheless using diffrent applications, talking to vendors isn’t going to solve the initial problem. Is there a way to automatically rename those files and replace them if the are synced via desktop client?

I would assume that the Workflow external scripts app is the right choice to do the job. You can call a script which renames the file. To be honest, I haven’t tested it yet :wink:):

#!/bin/sh

if [ -n "$1" ]
then
    # "%n" parsed as first parameter
    oldname="$1"
    newname="`echo "${oldname}" | sed -e 's/Ä/Ae/g' -e 's/Ö/Oe/g' -e 's/Ü/Ue/g' -e 's/ä/ae/g' -e 's/ö/oe/g' -e 's/ü/ue/g' -e 's/ß/ss/g'`"
    dirname="`dirname ${oldname}`"

    # rename file
    mv "${oldname}" "${newname}"

    # force file scan of the directory
    occ files:scan --unscanned --path=${dirname}
fi
3 Likes

Could you tell me how to implement that script? I’d like to try that but haven’t used the Workflow App before, I also have only very limited programming knowledge :slight_smile:

As I wrote, I haven’t tested the script nor am I using the workflow app on my own. I would recommend to read the description of the app to get an idea how it works an how a script can be called.

See also:


I’m sorry but I still don’t know how to execute the script…

I assigned it the ending .sh, is that correct?
The script is located in /OwnScripts/RenameUmlaute.sh

The message “The script does not seem to be executable” means that it cannot be executed by a shell command. You should grant execution right to the script, like “chmod +x <script-name>”. Additionally you need to parse the desired parameters to the script, by e.g. adding “%n” to the command line of the script.

Alright, the script is now actice. The filter is set to “User group membership - is member of - admin” and Run Script is set to “chmod +x /OwnScripts/RenameUmlaute.sh -f %n -o %o”. The parameters I used are from the article you linked.

The script doesn’t do anything at the moment, maybe because it is not working like you suggested or (more likley) I messed something up…

The “chmod +x …” command only need to be executed ones on the script and NOT in front of the script call itself.
Additionally make sure that the Nextcloud background cron job runs on a regular base because it is used to execute the command.

@j-ed thank you very much for trying to solve my problem, I am still unable to get it working.

Maybe someone else encounters exactly this problem aswell and I can copy :slight_smile:

Until then I simply sync all files to windows and let some windows programs do the job.