-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom script for rename files #1
Comments
Thanks for checking out my project. I made it for my own use and was curious if anyone else would find it useful. I'd suggest experimenting with a function in a Xcode playground. The kind of function you need is like (as defined by the typealias RenameCommand.RenameFunc):
In your ParsableCommand type, you'd end up using it simply like:
Or anything like that. It might make more sense to you, or might be easier to test & debug, or have a function like:
which you'd end up using in your ParsableCommand type like this:
From your email you seem to be trying to write an extension on String. If you indeed did that then you'd use like:
Whichever way you do it, writing this function separately in a playground lets you quickly iterate and try with new input until you're satisfied it will work, eg. by having the playground include just your function (doesn't need to import RenameCommand or ArgumentParser), and then follow it your own calls to it like:
About the code you included in your email, its seem far too complicated and admittedly I didn't try to follow it. What I think you need is merely something like this:
Use it in your ParsableCommand object like my "myrename2" example above, combined with the other bits in the full example from my readme. Let me know if you're having any trouble with that and I can pretty easily give you the full solution. I'm wondering, are you going to use this with swift-sh? This lets you have a swift "script" file you don't have to worry about having a project for, compiling ahead of time, finding the compiled executable, etc. If you've been paying attention to the Swift Evolution forums, or news about it, then you might have learned that this kind functionality might soon be built into the general "swift" command without having to add on the "swift-sh" homebrew package. Sadly, I don't think it will be ready in a shipping version of Swift for a while, later this year at the earliest. |
Hello, I came across your repo that promising me. This is the only one of its kind. But I can not understand how to customize the script for my need. I am still at the beginning of my studies in computer programming but I thought I was comfortable enough in Swift.
I would like to rename about 5000 files that have this scheme there:
"Randomtext randomtext randomtext 848484984984.txt" To rename them in "848484984984.txt".
So I thought I could apply this treatment here:
Unfortunately I can only have this result in my terminal.
'RandomText Randomtext Randomtext 848484984984.txt ' not Renamed
Would you have the kindness to help me? I thank you in advance
The text was updated successfully, but these errors were encountered: