I'm looking for a way to search for and delete files which end in a specific character - directory

I have a large ebook library which I have somehow managed to duplicate. Each .pdf is stored within its own individual folder inside a directory.
The pdf's have been duplicated in their original location, and have an identical file name except with a "2" at the end of each file name.
Is there a way to automatically delete all files within a directory, and all subdirectories, whose file name ends with a "2"?
For example, in one directory there are two files:
"Tolle_2001_thepowerofnow.pdf"
"Tolle_2001_thepowerofnow2.pdf"
I would like to delete the second file, but there are thousands of these folders in my ebook directory.
Thanks for your help!

Related

Why does the group of some file show number (looks like ID), not an alphabet string?

Normally as 'ls -al', the files always show like:
-rw-r--r-- 1 owner_name group_name size time file_name
But some of my files show:
-rw-r--r-- 1 owner_name 'number' size time file_name
And the 'number' does not exist in /etc/group
What does the 'number' mean? and how to fix it?
Many thanks!
The number is the group ID (gid). Groups and Users in a *nix system are numerical IDs (uid and gid). In a file system, the owning user and group will only ever be stored by its ID.
To display this, the user database is queried. With a modern *nix system, this could be anything, e.g. an LDAP directory, but the classic format is using the files /etc/passwd and /etc/group. If you see an ID instead of a name, it means your system couldn't find the entry in the user/group database. With a remote LDAP directory, this happens e.g. when the network is down. If you just use a traditional /etc/group file, this only happens when there is no entry.
Either the group was deleted or somebody changed the group of the file using a (non-existing) ID instead of a name or the file was copied from another system having this group and preserving the IDs while copying.
How to fix it depends on what you want. You can just chgrp the file to an existing group. Or you can create a group with this ID.
The numbers will be the group id's as opposed to the group name. To display group id's without group names, you can use ls -aln.
If a number shows amongst the names this is normally an issue with group name resolution i.e. if a group of files have been downloaded from an outside source and the group id's/names are "foreign" and therefore not understood by the local system.

Download files without knowing the extensions

I had an excel file which had for each row a column named id with a link value that open up other files the id doesn't have .(extension) on it.
The problem is that I imported the excel file on SQL Server Management, and the links is now strings without extension i want it to be displayed as a link in my grid view on asp.net page to open up the named file...
To mention there is at least 700 rows on the database.
Thanks in advance!

Remove files older than 18 months in UNIX (date in file name, not timestamp)

I want to delete log files which are older than 18 months from a directory. But deletion should not be based on the timestamp of file.
It should be based on the name of file.
Kindly help us to remove these files?
S14444225.SLS.20150131073838 (No need to Delete),
C14444210.ITM.20150131073838 (No need to Delete),
O14444216.OUT.20150131073838(No need to Delete),
S14444225.SLS.20130131073838(need to be Deleted),
C14444210.ITM.20130131073838(need to be Deleted),
O14444216.OUT.20130131073838(need to be Deleted)

Filter on directory and all subdirectories in Google Analytics

I am trying to set up a filter to include only data for a particular directory and all its sub directories.
For example, I would like to include data from dogs directory and subdirectories
http://www.mysite.com/dogs/
http://www.mysite.com/dogs/index.htm
http://www.mysite.com/dogs/breeds.htm
http://www.mysite.com/dogs/puppies/
http://www.mysite.com/dogs/puppies/index.htm
http://www.mysite.com/dogs/puppies/care/
http://www.mysite.com/dogs/puppies/care/feeding.htm
When creating a new filter I think I should select a Pre-defined filter to Include only traffic to the subdirectories that begin with the subdirectory /dogs/ and not case sensitive.
I am just a bit confused about whether it should be that begin with or that are equal to. Am I right to use that begin with in my situation and is my subdirectory value correct?
(I ask because it takes 24 hours for the data to update so getting it wrong costs a lot of time)
Turns out I was right. To filter on a directory and all subdirectories the settings should be
Predefined-Filter
Include Only
traffic to the subdirectories
that begin with
/dogs/
Not case sensitive

Can I copy all tables from a URL?

My task is to copy tables from a public domain and format it later in Word. I have created a software where I just have to enter two values and the table is displayed to me on a web page. Then I have to copy this table into Word.
I was wondering if there was an easier way to achieve this....
I would even like to know if it is possible to store all the values I type to a TXT file or Excel sheet and programmatically copy the displayed web pages to Word.
Please help me and don't down-vote.....
Okay here are the detailed steps:
Open a webpage
Fill in a form with 4 fields
A new webpage opens based on what input you provide
Copy 2 tables from that webpage
Paste the 2 tables in MS Word 2007
Open browser again and go back to previous page
Enter new values in the webpage
Repeat all the steps
P.S There are more than 700 tables to be copied each week
I'm not sure this is what you need...anyway...
If you download the page (programmatically of course) you can parse it as XML (I assume it's a well-formed XML file otherwise you may have to use some dirty trick to find all tables). Then you can put all data on Word (by automation, you can even do all these stuffs from a Word macro, just download the HTML file, "parse" it to find tables and paste that text as HTML).
I would provide some example but it can't really be language-agnostic.

Resources