LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-31-2016, 12:31 PM   #1
jkellogg
LQ Newbie
 
Registered: May 2013
Posts: 11

Rep: Reputation: Disabled
Question Help creating script to process files in folders


OK, gots a good one for you Linux gurus out there. I need to create a script that will parse a folder full of folders. In each subfolder there are several files, only one of which I need. I want to take the one file, which has a specific file extension, and move it to a different folder for further processing. The ability to specify the file extension or use multiple extensions would be a big help. I then want to be able to delete the subfolder regardless of any remaining files. The number of subfolders changes from day to day, so a for loop will probably be in order. Any help? Thanks in advance!!!

Last edited by jkellogg; 07-31-2016 at 12:32 PM.
 
Old 07-31-2016, 01:31 PM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
This can be done. How far have you gotten, and where are you stuck?

Best regards,
HMW
 
Old 07-31-2016, 02:37 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 24,111

Rep: Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098Reputation: 7098
Quote:
Originally Posted by jkellogg View Post
OK, gots a good one for you Linux gurus out there. I need to create a script that will parse a folder full of folders. In each subfolder there are several files, only one of which I need. I want to take the one file, which has a specific file extension, and move it to a different folder for further processing. The ability to specify the file extension or use multiple extensions would be a big help. I then want to be able to delete the subfolder regardless of any remaining files. The number of subfolders changes from day to day, so a for loop will probably be in order. Any help? Thanks in advance!!!
Not really a "good one", since this is so frequently a homework question, that there are THOUSANDS of sample scripts to do this. And you can probably even read your previous thread where you ask how to sort and move files, and where someone handed you a script:
http://www.linuxquestions.org/questi...lp-4175563871/

...and use IT as your starting point. We are happy to HELP you, but don't ask us to write your scripts.
 
1 members found this post helpful.
Old 08-01-2016, 06:47 AM   #4
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,391
Blog Entries: 13

Rep: Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455Reputation: 4455
This seems a highly complicated script which requires interactive behavior? Really, think about it, something that parses tons of files in folders and then upon the whim of whatever decides to move an arbitrary file from one place to another.

That's like a file manager/organizer application.

And what in the world is wrong with:
Code:
find . -name "*.dat" -exec mv {} <where you want it to go> \;
If you're asking this question for fun, your own amusement, your own learning experience, then make some effort on your own. Note that most of us would rather write code to save our own time versus reinvent things arbitrarily. Whatever you've specified doesn't seem anything useful or more special than existing capabilities that can be done either extremely easily or by using applications which already exist.
 
1 members found this post helpful.
Old 08-01-2016, 07:45 AM   #5
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
This forum is littered with such scripts.
 
1 members found this post helpful.
  


Reply

Tags
files, folders, move, parse, script


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating a script that will move completed downloads into other folders? Springs Linux - Newbie 1 12-01-2012 06:46 AM
Permissions when creating files&folders rbalaa Linux - Newbie 3 04-09-2011 05:50 PM
Need help with script to organise files into folders as part of DVD backup script jasybee2000 Linux - Newbie 5 06-15-2009 07:29 PM
Fedora: Error creating folders or writing to files thecrozz Linux - Software 1 02-02-2006 07:12 AM
creating files/folders accessing root folder remotely NapalmBob Linux - Networking 2 09-24-2004 10:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration