user2520969 February 2016

Name of file with ? at the end

I have a series of files. When i see them, by terminal, i get this:

ls
filename1^J
filename2^J
filename3^J
filename4^J

But when i open them through Finder application i get this:

Finder
filename1
filename2
filename3
filename4

So, i make a simple Java program, based on the method below, to change their name e fix this situation:

String newPath = file.getAbsolutePath().replace("^J", "");

But it doesn't fix the problem. So, how can i rename those files?

Answers


user2520969 February 2016

I solved using this simple solution:

filename = filename.replaceAll("[^a-zA-Z0-9.-]", "_");

I hope this can be useful to others

Post Status

Asked in February 2016
Viewed 1,265 times
Voted 9
Answered 1 times

Search




Leave an answer