Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Allocating names to folders based on a file Post 302972009 by A-V on Thursday 28th of April 2016 10:27:45 AM
Old 04-28-2016
Question Allocating names to folders based on a file

Hi everyone,
I have a problem and I would be gratful if you can help.

I have set of folders with files in them. e.g. data1, data2, data3
and I have a json file with info ... looking like this

Code:
[
	{"gender": "f",  "age": "15",   	"folder": "data1"},
	{"gender": "f",  "age": "15",   	"folder": "data2"},
	{"gender": "m"  "age": "15",  	"folder": "data3"},
]

I want to rename my files to replace the data with their gender to some processing and back to the real name later on...
Code:
f1
f2
m3

Do i need to convert the json file first? perl or awk?
or can data just be extracted (using awk?) and then folders changed based on that?

Thank you for your help....
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

File names based off of wildcards

Hello all- First post, so just to forewarn you: I know enough about Perl and the Terminal to get myself into trouble, not quite enough to always get out. I'd like to know if it is possible to, from the command prompt, use a wild-card to declare the names of files for input and then use the... (1 Reply)
Discussion started by: tcquad
1 Replies

2. Shell Programming and Scripting

Separate based on file names

Hello experts, This might prove to be a stupid question to some of you, but I have tried to tackle it in different ways. Being new to shell scripting, I am requesting your help in coming up with an elegant solution. I am using Korn shell. We have a directory with file names with the pattern:... (2 Replies)
Discussion started by: prashk15
2 Replies

3. Shell Programming and Scripting

Archive different folders based on their names

This is my first post so ... be gentle:) Hello I have several folders that are backed up daily in following format: /back_YY.MM.DD/backup1/* ........................./backup2/* I looking a script to archive and rename all backup folders bazed on root folder... (8 Replies)
Discussion started by: vilibit
8 Replies

4. Shell Programming and Scripting

Sorting file based on names

Hi I have some files in directory and the names of files are like jnhld_15233_2010-11-23 jnhld_15233_2007-10-01 jnhld_15233_2001-05-04 jnhld_15233_2011-11-11 jnhld_15233_2005-06-07 jnhld_15233_2000-04-01 ..etc How can i sort these files based on the date in the file name so that ... (4 Replies)
Discussion started by: morbid_angel
4 Replies

5. Shell Programming and Scripting

Ordering Folders having Date as Names

Hi All, I have directories under /development/arun/weekly/ 20120421 20120414 . . . . I need to arrange these directories in descending order. folder name with recent date will be on top and then others. (1 Reply)
Discussion started by: Arun Mishra
1 Replies

6. OS X (Apple)

Remove leading spaces from file names and folders

Hi All, I have a vexing issue with leading spaces in file names. Basically, we're moving tons of data from our ancient afp file share to Box.com and Box forbids leading spaces in files or folders. The HFS file system seems to be perfectly fine with this, but almost all other Unix file systems... (1 Reply)
Discussion started by: prometheon123
1 Replies

7. Shell Programming and Scripting

Files with same names in different folders

Hello, I am looking for a command line that can do some operations on two files that have the same names but in different folders. for example if folder A contains files 1.txt, 2.txt, 3.txt,.. folder B contains files 1.txt, 2.txt, 3.txt,.. If I would like to concatenate the two files... (6 Replies)
Discussion started by: Mohamed EL Hadi
6 Replies

8. Shell Programming and Scripting

Sort html based on .jar, .war file names and still keep text within three groups.

Output from zipdiff GNU EAR comparison tool produces output in html divided into three sections "Added, Removed, Changed". I want the output to be sorted by jar or war file. <html> <body> <table> <tr> <td class="diffs" colspan="2">Added </td> </tr> <tr><td> <ul>... (5 Replies)
Discussion started by: kchinnam
5 Replies

9. UNIX for Beginners Questions & Answers

Consternation of multiple file names based on naming pattern

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

10. UNIX for Beginners Questions & Answers

Sort a text file based on names in square brackets

Hi all, I have a text file similar to this: Text More text Etc Stuff That Is Needed Etc Etc This contains over 70 entries and each entry has several lines of text below the name in square brackets. (5 Replies)
Discussion started by: Scally
5 Replies
The object management API.(3)					      libmtp					     The object management API.(3)

NAME
libmtp - The object management API. Functions int LIBMTP_Delete_Object (LIBMTP_mtpdevice_t *, uint32_t) int LIBMTP_Set_Object_Filename (LIBMTP_mtpdevice_t *, uint32_t, char *) Detailed Description Function Documentation int LIBMTP_Delete_Object (LIBMTP_mtpdevice_t *device, uint32_tobject_id) This function deletes a single file, track, playlist, folder or any other object off the MTP device, identified by the object ID. If you delete a folder, there is no guarantee that the device will really delete all the files that were in that folder, rather it is expected that they will not be deleted, and will turn up in object listings with parent set to a non-existant object ID. The safe way to do this is to recursively delete all files (and folders) contained in the folder, then the folder itself. Parameters: device a pointer to the device to delete the object from. object_id the object to delete. Returns: 0 on success, any other value means failure. References LIBMTP_mtpdevice_struct::params. int LIBMTP_Set_Object_Filename (LIBMTP_mtpdevice_t *device, uint32_tobject_id, char *newname) THIS FUNCTION IS DEPRECATED. PLEASE UPDATE YOUR CODE IN ORDER NOT TO USE IT. See Also: LIBMTP_Set_File_Name() LIBMTP_Set_Track_Name() LIBMTP_Set_Folder_Name() LIBMTP_Set_Playlist_Name() LIBMTP_Set_Album_Name() References LIBMTP_file_struct::filetype, and LIBMTP_Get_Filemetadata(). Author Generated automatically by Doxygen for libmtp from the source code. Version 1.1.3 Sun Feb 17 2013 The object management API.(3)
All times are GMT -4. The time now is 05:52 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy