Skip to main content
Tweeted twitter.com/#!/StackUnix/status/365717514371612672
Remove thankyou text.
Source Link
Anthon
  • 81.4k
  • 42
  • 174
  • 228

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

Remove thankyou text.
Source Link

I'm fairly new to bash,bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

Many thanks in advace for any advice.

I'm fairly new to bash, I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

Many thanks in advace for any advice.

I'm fairly new to bash; I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

Source Link

Bash script to rename files from a text file source

I'm fairly new to bash, I can just about perform simple administrative tasks with simple commands 1 at a time. However, I've been tasked with renaming some files in a directory using a text file as the source for my renaming and would really appreciate a few pointers, as I am well out of my depth.

Let me explain:

New File Name.xlsx 0.1 000011F4.dat New File Name.xlsx 0.2 000011F5.dat New File Name.xlsx 0.3 000011F6.dat New File Name.xlsx 0.4 000011F7.dat New File Name.xlsx 0.5 000011F8.dat New File Name.xlsx 0.6 000011F9.dat 

The source text file I have resembles the above somewhat. The intention is that the first 'column' is the new name for the file, the middle is the version and the third is the current filename.

I need to rename the .dat files in the directory, changing them to the names presented in the first column. I also need to prepend the version number 0.1, 0.2 etc... to the beginning of each file.

I have a few questions:

Is it a massive problem that the files have whitespace in them? Would it be better adding " " around each file string?

Basically I have no idea where to start and any help would be massively appreciated. As you can see it's slightly more complex than a usual renaming, giving the need to add the version column to the beginning of the filename and the whitespace in the list.

Many thanks in advace for any advice.