Olyno / skent

Manage your files and folder with Skript
GNU General Public License v3.0
11 stars 2 forks source link

How to rename a file with the new method #20

Closed Misio12320 closed 2 years ago

Misio12320 commented 3 years ago

Describe your problem

Hello. I would like to request help and report a bug. The code should rename all files in the path which is in code. Might I wrong wrote the code, sorry them.

Versions

Skript: Skript version 2.5.3 Server: This server is running Purpur version git-Purpur-1022 (MC: 1.16.5) (Implementing API version 1.16.5-R0.1-SNAPSHOT) Skent: Skent version 3.0.0

Code

command rename:
    trigger:
        set {_files::*} to all files of dir path "plugins/Skript/scripts/yes"
        set {_files::*} to {_filess::*} in lowercase
        rename file path "%{_files::*}%" to "%{_filess::*}%"

its only 1 file named "TEST1.txt"

Error

https://pastebin.com/qgcyVAb5

Olyno commented 3 years ago

Your code is wrong. all files expressions gives you a list of path type, not string. so {_filess::*} in lowercase will not work. With this, {_filess::*} has not the same name of {_files::*}. Finally, if you had read the changes, you would have seen that this syntax had not changed.

The right code should be

command rename:
    trigger:
        set {_files::*} to all files of dir path "plugins/Skript/scripts/yes"
        loop {_files::*}:
            set {_name} to file name of loop-value in lower case
            rename loop-value to {_name}
Misio12320 commented 3 years ago

The code does not work.

command rename:
    trigger:
        set {_files::*} to all files of dir path "/plugins/xd"
        loop {_files::*}:
            set {_name} to file name of loop-value in lower case
            rename loop-value to {_name}
            broadcast {_name}

nothing is send. If you can then take a look in free time. I can wait @Olyno

Olyno commented 3 years ago

Okay so after having a better look in, it seems that the issue is not correctly fixed. I'm going to try another fix soon as possible.

Olyno commented 2 years ago

Fixed in the next release (3.2.0). Feel free to reopen this issue if it is not.