You are not logged in.

#1 2008-03-18 03:09:41

phabulosa
Member
From: Mountain View, CA
Registered: 2007-10-17
Posts: 182
Website

[Solved]Can I rename a file just by knowing its inode

Hi!
I have some files/directories with very weired characters in the filename.
So, I was unable to rename them to something that is accessible by its filename.

However, I can see their inode.
Is there anyway that I can rename a file just by using its inode?

thx

Last edited by phabulosa (2008-03-18 23:11:30)

Offline

#2 2008-03-18 04:30:37

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,365
Website

Re: [Solved]Can I rename a file just by knowing its inode

You can try using "find" to get the name of the file with that inode and then pipe that to "mv"

Offline

#3 2008-03-18 05:43:43

phabulosa
Member
From: Mountain View, CA
Registered: 2007-10-17
Posts: 182
Website

Re: [Solved]Can I rename a file just by knowing its inode

Allan wrote:

You can try using "find" to get the name of the file with that inode and then pipe that to "mv"

I need to do this on a embedded busybox environment, so the 'find' utility does not has a feature of -inode.

However, I achieved my goal by doing the following:
1. Figure out the inode of a file/directory by

ls -i

2. Use a variable to save the filename which cannot by typed in due to weired characters

xyz=`ls -i|grep 705|sed 's/48840705 //'`

3. Rename by

mv "$xyz" filename_I_want

Offline

#4 2008-03-18 08:34:37

loosec
Member
Registered: 2007-03-08
Posts: 134

Re: [Solved]Can I rename a file just by knowing its inode

Want to mark it 'solved' and make a wiki contribution? smile

Offline

#5 2008-03-18 17:15:00

tam1138
Member
Registered: 2007-09-10
Posts: 238

Re: [Solved]Can I rename a file just by knowing its inode

What about this:

find . -type f | (let i=0; while read f; do mv "$f" file-$i ; let i=$i+1; done)

(assuming you want to salvage names for all files in current directory)

Offline

#6 2008-03-18 23:12:29

phabulosa
Member
From: Mountain View, CA
Registered: 2007-10-17
Posts: 182
Website

Re: [Solved]Can I rename a file just by knowing its inode

loosec wrote:

Want to mark it 'solved' and make a wiki contribution? smile

How to easily quote this thread to form a wiki for Arch?

Offline

Board footer

Powered by FluxBB