Results 1 to 2 of 2

Thread: Rename folders as files inside

  1. #1
    Join Date
    Dec 2018
    Beans
    1

    Question Rename folders as files inside

    Hi,
    i have a problem with rename a lot of folders.

    There is a structure of my problem and what i need..

    I have many folders..
    for example:

    folder /0512-2018 contains files 78563412.txt and 78563412.rar

    ./0512-2018 -- 78563412.txt
    -- 78563412.rar

    and i need rename this folder as files inside this folder:

    ./78563412 -- 78563412.txt
    -- 78563412.rar

    Thanks so much!

  2. #2
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Rename folders as files inside

    ABSG will help you create a script: https://www.tldp.org/LDP/abs/html/
    Doesn't appear to be too hard. I would pick one of the files in the subdirectory (folders are a GUI thing), probably the txt file, and find it, take the basename, then move the directory containing that file {dirname} to {basename}.

    A little find + sed + dirname + basename + mv

    Is this a homework problem for a Linux class?
    Last edited by TheFu; December 7th, 2018 at 12:07 AM. Reason: added dirname

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •