Olyno / skent

Manage your files and folder with Skript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to rename a file with the new method

Misio12320 opened this issue · comments

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

commented

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}

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

commented

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.

commented

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