Coder Social home page Coder Social logo

jpmhouston / renamecommand Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 19 KB

A ParsableArguments implementation for making minimal rename scripts in Swift

License: MIT License

Swift 100.00%
swift-sh swift swift-package-manager argumentparser command-line rename-script regular-expression

renamecommand's People

Contributors

jpmhouston avatar

Stargazers

 avatar

Watchers

 avatar  avatar

renamecommand's Issues

custom script for rename files

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:

    public func componentsSeparatedByStrings() -> String {
        let separators = ["%20"]
        let arrayName = separators.reduce([self]) { result, separator in
            return result.flatMap { $0.components(separatedBy: separator) }
        }.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) } // ["RandomText, RandomText, RandomText, 848484984984"]
        let newName = arrayName.last
        return newName! //848484984984
    }

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.