Ubuntu :: Deleting Files Based On Number Created (or In Folder?)

Jul 21, 2011

I'm dipping my toes into some bash scripting and was wondering if there was a way to delete a file not based on how old it is, but rather how many other files are currently in the folder... or something to that effect....

What I'm doing is creating a script to back up a folder nightly. I'd like to keep a maximum of 3 backups. However in case the script for some reason fails to run one night (computer turned off possibly) I don't want to set the condition for deletion to be the date.

I know that if I run:

Code:
find /path/to/files* -mtime +3 -exec rm {} ;
that it will delete everything older than three days. -atime and -ctime don't seem to be what I"m looking for... is there another command I can use to achieve what I"m trying to?

View 5 Replies


ADVERTISEMENT

Ubuntu :: Renaming Video Files Based On The Date Created

Aug 4, 2011

I have hundreds of MTS and AVI files since 2000 and would like to rename them in the following manner based on the date created: DD-MMM-YYYY HH.MM.SS_X; where X begins at 1 and increments by 1 if there are dublicate date/time stamped videos.

Ex: 19-Nov-2002 08.12.30.avi, 19-Nov-2002 08:13:30_1 and 19-Nov-2002 08:13:30_2

Someone previously wrote the following script for me, and it works great for photos. It uses EXIV2 to get the image date created info. I have tried to understand the script, but am struggling. The video files I have can use the date modified since I have not modified them since I filmed them.

#!/usr/bin/env python
import os
import stat
import pyexiv2
import time
directory = '/home/david/Desktop/test'
[Code].....

View 1 Replies View Related

General :: List Folder Size And Number Of Files And Folders In Folder?

Nov 23, 2010

In Linux bash shell, for a given directory, how can I list:The create date for that directory The number of files in that directory The number of subdirectories in that directory.

View 3 Replies View Related

Ubuntu :: Sequentially Number Files Based On Date Modified - Rename Cli

Nov 8, 2010

Sequentially number files based on date modified (rename cli)

I'm almost done a larger script which takes all the pictures in a folder, converts it to video, and emails it to me. Everything worked fine until I realized the picture filenames weren't always starting at 1, then ffmpeg chokes.

I have a bunch of files in a folder which I need to rename to:

I don't want to install any additional packages and I'd like this to run in a single command if possible.

If not possible, then a bash script would work too.

View 3 Replies View Related

Software :: Join 2 Text Files Based On First Number Present In Every Line Of The 2 Text Files?

Jan 22, 2010

I have 2 text files : file1.txt and file2.txt

cat file1.txt

15 this is a sentence containing various words and spaces
34 this is a another sentence containing various words and spaces

cat file2.txt

2 this is sentence1file2
6 this is sentence2file2
54 this is sentence3file2

I would like to join these 2 files. The result should look as follows :

cat joinedfile.txt

2 this is sentence1file2
6 this is sentence2file2
15 this is a sentence containing various words and spaces
34 this is a another sentence containing various words and spaces
54 this is sentence3file2

==> so the joined file must be sorted on the first number. Any ideas how this can be achieved ?

View 4 Replies View Related

Ubuntu :: Created A Little Bash Script For Renaming Files From A Folder?

Feb 28, 2010

I created a little bash script for renaming files from a folderEvery time i hv to put that bash script file (rename.sh) in folder Is there any ways i will call (rename.sh) from terminal without moving rename.sh into any folder ?ne More Question : Whenever i run any .sh file automatically one .sh~ file created it is my programing mistake or is it exists ?

View 7 Replies View Related

General :: "Argument List Too Long" - Deleting Files Based On Grep?

Jan 28, 2011

I've got a directory with thousands of files and I want to delete those that contain specific text.When I try:Code: ls | grep -l "specific text" * | xargs rm I get the error: Code: /bin/grep: Argument list too long Is there an easy way to get around this without having to move files into seperate folders and processing them in batches? I found an article on getting around this problem, but I'm kind of new to Linux and don't know how to apply this to my specific problem.

View 3 Replies View Related

Server :: Cant Edit Files Which Are Created In Samba Shared Folder

Sep 29, 2010

i have created an folder inside my redhat server. and i shared it via samba and mapped that shared folders inside 5 windows machine. now the problem i am facing is, if any one create a file in that mapped drive the other user cant edit that same file. but he can read it. only for files not folders.

i gave full permission to that folders and subfolders and in smb file i gave readable writable browsable permissions. and i disabled se linux and firewall

View 12 Replies View Related

Programming :: Shell Script To Monitor Files Created On A Folder

Aug 27, 2009

Can someone please help me on how can i create a script that will monitor file creation on a single folder and sending the newly created file on a separate folder? Only the new created file must be transffered or copied to the other folder. The old ones remains.I urgently need this for production deployment.

View 8 Replies View Related

Ubuntu :: Rename Files - Add Number To All In Folder ?

Feb 14, 2010

Getting together a script that will add numbers to all the files in a folder.

I've ripped most of my CDs to oggs for my new pmp, but I found that the pmp doesn't like files that are numbered just as 1 and 2, as it thinks that the 2 is more than 10.

So instead of going through all of my music folders and renaming every file by hand from 1 to 01 and from 2 to 02, I'd ask if there's a script that can be executed to add these numbers for me. It'd be even better if it only added the number to the files with only one digit.

Here's an example:

I want to rename:

And I'd like to do it to all single-digit files lower than 10 in the folder, if possible. If not, I can isolate them by hand.

View 4 Replies View Related

General :: Maximum Number Of Files Per Folder?

Apr 28, 2011

I would like to ask you if there is any maximum allowed number of files per folder in linux (without risking it to lose everything). I am using openuse 11.4 with latest kde (4.6?).

I am trying something fast and dirty and it might be that one folder will contain like 10^6 files.

Is there is anything I should be warned about that?

View 10 Replies View Related

Ubuntu :: Create Folder',and Results In An Empty Folder Being Created On Desktop?

Oct 29, 2010

I have this nasty habit of refreshing desktop in a quick succession by right-clicking and selecting 'Refresh',on my XP system at office.(And,iam sure most of us do the same).With Ubuntu,if a right-click on desktop slowly and select 'align by...',it simulates the XP refresh action as explained above.But,if i perform the same action rapidly,it takes this first option from right-click context menu,which is 'Create Folder',and results in an empty folder being created on desktop.I tried double right-clicking and again it created an empty folder.Is there any workaround to handle this.I mean:Can the right-click context menu items be shuffled so that the 'Create Folder' option is moved from 1st place

View 9 Replies View Related

Programming :: Search A Bunch Of Files In A Specific Folder For A Specific Number?

Jul 24, 2010

I need to search a bunch of files in a specific folder for a specific number and add all the numbers together to a total sum. I use Rsync everyday, everytime I run rsync i get a logfile (rsync output) witch contains the textstring "Total bytes sent: xxxxxx".

The "xxxxx" can vary in lenght. I need to extract the "xxxxxx" from each file and add the numbers together to a total size over a week or a month. Is this possible? And I wish to only use bash. One way of doing stuff at a time my friends .

View 5 Replies View Related

Networking :: Ip Routing Based On Port Number?

Sep 30, 2010

I have 3 gateways in my office. I want to redirect all web traffic (port 80 and 443) through one gateway and ssh connections through other one. All machines have single network interface. For this what I did is created an ip alias et0:1 and assigned ip to it. Then wrote an ip route rule to route packets from eth0:1's ip to other gateway. All other traffic will go through default gateway. But here I am not sure how I can make web browser to use eth0:1's ip. It's using eth0 's ip. I wrote a ip table rule to change source ip of http packets to et0:1's ip. But rule is on POSTROUTING chain. So I think it's happening after routing.

View 4 Replies View Related

Ubuntu :: 'Are You Sure' Question Before Deleting Folder?

Nov 29, 2010

I accidentally hit the delete button on a folder. Luckily, it was still in the trash and I could restore it. However, I was wondering if there was a setting that could display an 'Are you sure?' question before deleting the folder in case this happens in the future again.

View 9 Replies View Related

General :: Folder In Window Its Not Showing The Folder Time Created Time Stamp?

May 20, 2011

I was created one folder in linux with current time was 1978(For example). I was moved this folder to usb(FAT32 file format).While seeing this folder in window its not showing the folder time created time stamp, because the USB file system only support the year after 1980 . But again i am putting the same folder in linux ,its showing the correct time stamp.How is it possible? Because FAT32 only supports timestamp after 1980, but still its showing 1978 in linux system

View 7 Replies View Related

General :: Get Week Number Based On Date With Different First Day It In Gawk?

Jun 24, 2011

How to get the week number in linux using gawk with different first day of the week? the date command can give me the week number with +%V but it is based on Monday (1-53) or +%U (based on Sunday, 0-53).

I tried to to do this: date -d "ddmmyy+2days" +%V, but the result is not correct. I want the first day of the week is based on Saturday.

View 1 Replies View Related

Ubuntu :: Deleting Folders From The Home Folder?

Jul 7, 2011

I accidentally created a folder in my /home directory and its ticking me off because i cant delete it and im anal about my organization on the computer and having this extra empty folder.

View 5 Replies View Related

Ubuntu :: Delete Desktop Folder Without Deleting Contents

Oct 7, 2010

Im assuming there is a simple answer for this but I have yet to find it in forums. I have 2 partitions mounted on my ubuntu desktop, one is Windows C: drive labeled "Core" and the other is D: drive labeled "Reserve" but for some reason I have a second Windows folder on my desktop, when I attempted to delete it it began to delete the Windows files as well, one forum said to right click and "remove from desktop" but this option isnt in the menu. How can I just delete the folder?

View 2 Replies View Related

Ubuntu :: Persistent Content Of /tmp Folder Returns After Deleting Or Rebooting?

Apr 6, 2010

After checking my tmp folder I found out some strange hidden and unhidden folders of programs that I have not used or downloaded. After removing each one using sudo rm -rf some folders insist on re-appearing, and after a reboot all folders are back.

Moreover, trying netstat -l, found that many of these files are in listening state.

How can I permanently erase them?

View 3 Replies View Related

Ubuntu One :: Deleting Files From Web Interface Erase Files From Computer?

Nov 27, 2010

Does deleting files using the Ubuntu One web interface delete the files stored on my computer?

View 1 Replies View Related

General :: Finding Out Why/how A Folder Is Being Created

Jun 22, 2010

There's a folder on my Linux desktop which shouldn't exist. The first time I saw it, I thought I'd accidentally copied it from somewhere else, so I deleted it. Now it's back again. So it must have been automatically created by some process, but what can I do to figure out which program is creating it? I think it's likely that if I delete the folder it'll eventually be created again, so I should be able to catch this program in the act if anyone can suggest a technique for doing so. By the way, there are no files in this mystery folder, and its name is the same as another folder I created months ago to hold my personal documents, not something that a program would create to hold its own configuration files or the like.

View 2 Replies View Related

Ubuntu :: Deleting Folder And Its Contents From Terminal / Sending Permission Error?

Jun 10, 2010

how do i delete a folder and its contents from terminal? when i tried to delete the folder it returns a- permission error,,-

View 2 Replies View Related

General :: No App Folders Being Created In Home Folder / Why Is So?

Jun 14, 2010

No app folders being created in home folder. For example, when I do something like code...

View 3 Replies View Related

General :: Why Are No Application Folders Being Created In Home Folder

Jun 15, 2010

For example, when I do something like...

sudo apt-get install vim

No .vim folder is created in the home folder.

View 1 Replies View Related

General :: Desktop And .nautilus Folder Can't Be Created On Startup?

Feb 20, 2011

I changed some settings to see what will happen ( specifically to login with having to type my password) and now I can log in without a password. The problem is that I think that my password is still required, but now I can't use my laptop. Here is what happens log in (it doesn't ask for a password), then I get the error that it can't update ICEauthority, then I get the error "There is a problem with the configuration server./usr/lib/libconf2-4/gconf-sanity-check-2 exited with status 256)I also get the error that Nautilus can't create my Desktop folder and .nautilus folder.The problem is that I do not have another account, as in no root account. Each time I had to do administrative tasks ,like install software, etc, i used the cli with sudo and the command. If I wanted to do a few commands, I usually entered sudo -i

View 2 Replies View Related

Server :: Default Size Of A Newly Created Folder?

Dec 4, 2010

I just want to know how the default size of a newly created file or folder is 4.0 kb.Does this value is mentioned in any configuration file,if that is the case can we edit that file and can we change this default value.

View 7 Replies View Related

Programming :: Know Which File Under The Folder Is Being Opened / Created For Writing?

Apr 23, 2010

My program need to monitor the foler to know which file under the folder is being opened/created for writing. I add the folder into watch list using inotify_add_watch, when a file -- say 'AA' -- is created, I'll get the event through read api call. But the inotify_event only have file name 'AA' and a event mask. these parameters can't help me to know how the 'AA' is created/openned. So I have to scan the /proc folder to get to know how is 'AA' created/openned. I don't think this is a efficient way, especially if there are lots of files are openned/created in a short time span.

View 3 Replies View Related

General :: Can't Make New Folder Or Copy Paste In Newly Created Partition?

Mar 17, 2011

I just maked an ext4 partition by the help of gparted. Ubuntu is my only OS no dual boot. Using Ubuntu Maverick. The problem is partition must be open as root to do any work else it wont even allow me to open file,create folder,cut copy paste or anything.

View 9 Replies View Related

Security :: Created A .htaccess File In The Folder And Added AuthType Basic?

Jan 26, 2010

I have a folder on my server i want to protect with http authentication but i have problem. i created a password htpasswd -c .htpasswd razzera

then i created a .htaccess file in the folder and added
AuthType Basic
AuthName "Restricted Files"
# (Following line optional)
AuthBasicProvider file
AuthUserFile /.htpasswd
Require user razzera

but when i go tho the folder it wont request any login details. why ??

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved